Prof A Olowofoyeku (The African Chief) wrote:
For example, in system.pas, this code: "procedure GlobalMemoryStatus (var Buffer: TMemoryStatus); attribute (stdcall, name = 'GlobalMemoryStatus');"
produces this result; c:/mingw/bin/../lib/gcc-lib/mingw32/3.2.2/units/system.pas: In procedure `GlobalMemoryStatus': c:/mingw/bin/../lib/gcc-lib/mingw32/3.2.2/units/system.pas:791: parse error before `to'
Now, if I change the code to: "procedure GlobalMemoryStatus (var Buffer: TMemoryStatus); external name 'GlobalMemoryStatus'; attribute (stdcall);"
or: "procedure GlobalMemoryStatus (var Buffer: TMemoryStatus); attribute (stdcall, name = 'GlobalMemoryStatus');external;"
the problem disappears. The important word here is "external".
You're right. (I couldn't test this case, obviously, and since previously external and non-external weren't properly distinguished, such confusions were to be expected.)
But the error message generated when it is missing seems misleading.
Not at all. The code defines a regular procedure which has some local subroutines `MemAvail' etc., and where the `begin' of the procedure should follow, `to begin do' is found. Up to this point, the source is valid (though not as intended, but the compiler can't guess that).
In dos.pas, the code: "{$define WINAPI(X) external name = X; attribute (stdcall)}"
produces this result: c:/mingw/bin/../lib/gcc-lib/mingw32/3.2.2/units/dos.pas:697: parse error before `='
If I change it to: "{$define WINAPI(X) external name X; attribute (stdcall)}"
the problem goes away. So, the problem here is with the construct "external name = foo". If you remove the "=" and change it to "external name foo" then there is no problem.
Right.
Frank