Re: Informix / C parameter passing
Posted in 1993
}Date: Mon, 15 Nov 93 16:59:36 MST }From: alan@po.den.mmc.com (Alan Popiel) }To: informix-list@rmy.emory.edu, johnl@informix.com }Subject: Informix / C parameter passing }It appears to me that this is EXTREMELY 4gl-version dependent. The documented way of handling values in user functions has not altered since 1.00 I4GL, except for the addition of new data types (VARCHAR, DATETIME, INTERVAL, BLOB). This was the gist of my comments; I do not know of ANY version of I4GL where the I4GL-to-C interface was changed from the one documented in the Version 4.00 I4GL Reference Manual, Vol 1, p 2-64 to 2-69. Yes, if you are calling I4GL from C, then the fglapi.h interface was defined relatively recently (4.00 or 4.10, I forget which). But the I4GL-to-C interface is not at all version specific. }Once again, here is the 4GL for my empty function, followed by the C }generated by the version 2.10 compiler. } }empty.4gl }--------- }FUNCTION empty ( a, b, c ) }DEFINE a, b CHAR(256), } c CHAR(512), } d CHAR(512) }RETURN d } }empty.c (produced by version 2.10 c4gl) }------- }empty (fgl_pcnt) }int fgl_pcnt; }{ } char a[ 257 ], b[ 257 ]; } char c[ 513 ]; } char d[ 513 ]; }if (fgl_pcnt != 3) fgl_fatal(fgl_modname, 6, -4501); }popquote(c,513); }popquote(b,257); }popquote(a,257); }pushquote(d,512); }doretalloc(1); }return(1); }} }Perhaps in version 2.10 the 'doretalloc' call served the 'retquote' purpose. Well, the source for retquote() does boil down to: pushquote(s); doretalloc(1); only expressed somewhat differently. }I don't know: It's your (Informix's) code generator. I chose not to use it, }and the function still works. That is fortunate. On 95% (or more) of machines, you'll be OK because there are no intermediate function calls which trample over the returned string. But you are treading on thin ice because you aren't using the defined interface. }I stand by my statement to compile empty.4gl and then modify my function to }use the same sort of calling and return sequences that you find in the }resulting empty.c. But I don't remember seeing the "doretalloc(1)" in your code. And do you know what the 1 means? If not, use the documented interface, which doesn't change. Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>