Rick Engebretson wrote:
Prof A Olowofoyeku (The African Chief) wrote:
There is something else which has been exercising me, in respect of imports from Windows DLLs. In gcc, I can do something like this:
FARPROC foo; /*pointer to DLL function "char *foo (char *x, char * y, int z)" */
void main(){ char *str; HINSTANCE h = LoadLibrary ("myfoo.dll"); if (h > 0) { foo = GetProcAddress (h, "foo@12"); str = foo ("foo", "bar", 24); } }
In GPC, this kind of thing will (naturally) not work, because the (function) pointer "foo" cannot be passed arbitrary parameters like that. gcc happily accepts it (now, of course, if the parameters are wrong, then the program will GPF at the call "str = foo ...", and if the parameters are correct, then everything works correctly). The question is: since GPC is based on gcc, is the capacity to accept something like this present in GPC? (the question whether it should be accepted of is of course a different thing). I personally would find it very useful (not for translating c headers, but for automated parsing of DLLs and automated imports of their exported symbols), although I can hear all the cries of "Pascal is a safe language and therefore should never accept something like this".
Best regards, The Chief
Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/
I'm not going to pretend expertise here.
But one irony comes to mind. Early Windows(eg; 3.0) passed "pascal parameters" to C lib functions and required their declaration as such. So we have come full circle.
To quote from "Charles Petzold; Programming Windows 3.1," 1992, Microsoft Press, page 12.
/* You use these Windows functions in your Windows program the same way you use C library functions such as "strlen." However, there are some differences between the Windows functions and the standard C library functions. Windows functions are always declared as "far pascal" functions. The "far" keyword... The "pascal" keyword indicates the functions calling sequence is different than the normal C calling sequence. ... The "pascal" calling sequence is used in Windows because it is more efficient.*/
I don't know if later Windows is the same or not.