On 2007-05-24 15:25-0600 Orion Poplawski wrote: > In plplot-5.7.3/examples/ada/x12a.adb, the sprintf function is declared > and imported as follows: > > procedure Sprintf( buffer : out char_array; format : in char_array; > variable: in PLFLT ); > pragma Import(C, Sprintf, "sprintf" ); > > This is incorrect because sprintf's declaration is sprintf (char *, > const char *, ...) (varargs) not sprintf (char *, const char *, float). > This happens to work on i386 because of the ABI happens to be the > same. It isn't on x86_64 and so crashes. See > https://bugzilla.redhat.com/bugzilla/process_bug.cgi#c1 and the > http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Calling-Conventions.html note > about varargs for more info. > > If you really need to use sprintf you'll need to write a write a > sprintff(char *, const char *, float) wrapper to sprintf and interface > to that. Likewise for any other arguments used (currently just the one). > > Not sure if any plplot routines use varargs arguments, but if so the > current ada imports are probably incorrect.
Thanks, Orion, for your report. To answer Orion's last comment first, I looked in src/*.c for "..." and there doesn't seem to be any libplplot routines with a variable number of arguments so I don't think that is going to be an issue. To answer Orion's second-last comment, I think we should look for an Ada alternative to Importing the C sprintf function because of the difficulties you have found with that method. Virtually every language has a native way to transform from integer, floating-point etc. representations, to strings. Jerry, are you aware of the normal way to do this in Ada? N.B. this has nothing to do with API questions or our Ada interface and is merely a question about how to transform from integer and floating point representations to strings in Ada since that capability is needed for the Ada implemention of example 12 and several other of our examples. 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 DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel