On 4 Mar 2005 at 20:16, Waldek Hebisch wrote:
[...]
So, AFAICS you can not entiterly omit info about arguments
[...]
So, how come gcc can do it? Is this a peculiarity of C compilers, or is it something unique to gcc than cannot possibly be enabled in gpc?
- All parameters in C are passed by value. Pascal has both "by value" and "var" parameters, and the compiler needs declarations to correctly pass arguments. Also, Pascal constants represent values, and parameter types allow to
Yes.
- AFAIK even on Windows you need to specify correct calling convention, otherwise if it is different then the default the program will crash
Yes, I am aware of that. My original example was simply to illustrate that, with gcc, you can simply declare something as "FARPROC foo", and then use "foo" in any manner you wish (including passing it an arbitrary number of parameters). The success of such an exercise naturally depends on everything else being correct.
- Declaring functions without giving parameter types is considered bad practice in C. You _are_ allowed to declare function having variable parameters (number of parameters and their types vary), but that is different then no declaration
Yes.
You can define variable argument functions in Pascal:
type fsi = function(...): integer;
Ok. I believe it used to be that there wasn't any way to use this (other than to import C library routines that have variable arguments). It seems now that it can be used.
The call will be performed as C call. Note that calling convention must match, and that constant arguments may go wrong (gpc tries to do what C compiler will do, but has less information).
Ok. This is quite helpful. Thanks.
Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) web: http://www.greatchief.plus.com/