Hello,
I need to pass an argument corresponding to C’s argv* from chapel to C. In my chapel code I have this:
extern proc plot(argc: c_int, argv: c_ptr(c_ptr(c_char)), x: [] c_double, y: [] c_double, xmin: c_double, xmax: c_double, ymin: c_double, ymax: c_double, size: c_int);
and call it like this:
var argc: int(32);
var argv: [0..5,0..10] c_ptr(c_ptr(c_char));
The code does not compile.
chpl -o chpl_driver plot.o main.chpl -L/usr/local/lib -lplplot
main.chpl:6: error: Could not find C function for plot; perhaps it is missing or is a macro?
gmake: *** [Makefile:13: chpl_driver] Error 1
I’m not certain, but I think the problem may be that the function prototype, which matches the call from chapel, does not match the function implementation:
int
plot( int argc, char *argv[], PLFLT *x, PLFLT *y, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, int NSIZE )
{
// Parse and process command line arguments
plparseopts( &argc, argv, PL_PARSE_FULL );
// Initialize plplot
plinit();
// Create a labelled box to hold the plot.
plenv( xmin, xmax, ymin, ymax, 0, 0 );
pllab( "x", "y=100 x#u2#d", "Simple PLplot demo of a 2D line plot" );
// Plot the data that was prepared above.
plline( NSIZE, x, y );
// Close PLplot library
plend();
return 0;
}
I have not tried interoperating with C before and would appreciate a bit of hand-holding.
Thanks,
Roger