On 2008-08-31 14:14-0700 Jerry wrote:
> My posting of this problem at comp.lang.ada has produced some rather arcane
> discussion.
>
> There is one school of thought that says that my example, being all Ada, is
> different than the real code (in PLplot) because plmap in my posted example
> is in Ada where in the real situation it is in C. The discussion revolves
> around how Ada handles calls to Ada subprograms while enforcing C calling
> conventions versus calls to C subprograms while enforcing C conventions.
>
> So, I'm trying to modify the simple example so that plmap is written in C,
> more closely emulating the PLplot situation. Unfortunately, my C skills are
> very poor and I can't get a simplified plmap to compile. My goal is to get it
> to compile then link to it from Ada.
>
> Here is my feeble attempt at C:
>
>
> ====== In a file called plot.h, there is this: ======
>
> void plmap( void (*mapform)(PLINT, PLFLT *));
>
>
>
> ====== In a file called plmap.c, there is this: ======
>
> #include "plplot.h"
> void plmap( void (*mapform)(PLINT, PLFLT *) )
> {
> int n;
> double xx[10];
> n = 10;
> (*mapform)(n, xx);
> }
>
> ======================================================
>
> Could someone tell me how to get this to compile? I'm just typing
>
> gcc plmap.c
My C skills are not that great, but I think I can help you out.
In plplot.h you have to define the PLINT and PLFLT types. I did that by
inserting the lines
#include <stdint.h>
typedef double PLFLT;
typedef int32_t PLINT;
(That first #include #defines what int32_t means [a 32-bit integer
regardless of platform] for C99 compliant systems. If you don't have
stdint.h accessible on your system, then replace int32_t by int).
Then the command
gcc -c plmap.c
works for me. The -c option is required because you just want to compile
that code and you do not want to link it to make a standalone executable out
of it.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________
Linux-powered Science
__________________________
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel