James Buchanan wrote:
Waldek Hebisch wrote:
In general GPC uses the same calling convention as C. However, Pascal has much more possibilities for parameter passing then C (variable parameters, conformal arrays) and extra types. Also, GPC adds some extensions to standard Pascal. Things which are not present in C are mapped to C-like constructs -- for example variable parameters are implemented by passing pointers (addreses of the parameters).
That's good. So to implement a printf-like function I am not looking at pass by value, I just need to remember I am dealing with pass by reference in all cases for varargs functions.
Variable parameters (Pascal term) are quite different than varargs (C term). For compatibility with C GPC supports calling varargs functions. GPC does not support writing varargs functions (you can write a trivial one, but there is no way to get the parameters). Note that Writeln is _not_ a varargs function. Writeln is converted by the compiler into calls for separate arguments -- no user defined function can behave the same as Writeln.