On 9 Mar 00, at 15:08, Mark Taylor wrote:
Subject: Re: How to compile hello.pas for win32
You need to import the WinAPI functions before you can call them.
I knew this was necessary, but did not know the syntax - is it documented anywhere? I looked for it (honestly) but couldn't find it. I must admit I didn't look in the info database, because I assumed that this would be so win32 specific it wouldn't be there.
The syntax for importing routines from the C libraries is documented (I can't remember where). As for the syntax for importing routines from the WinAPI, it is more or less the same as that for importing libc routines - but you need to declare them with the 'stdcall' attribute. You also need to use the 'asmname' directive, especially where the alias (imported name) of the routine is different from what it is called inside the Windows DLLs, but also because there are often two versions of a Win32 API call - one for ansi characters (ending with 'A' as in the 'GetModuleHandleA' example that I gave) and the other for wide (unicode) characters, ending in 'W' - and you need to specify which one you want.
e.g., {$define WINAPI(X) asmname X; attribute(stdcall)}
FUNCTION GetModuleHandle ( lpModuleName : PChar ) : Integer; WINAPI ( 'GetModuleHandleA' );
Are you saying I can do c-style #defines in a pascal program using a syntax like this?
{$define macro definition}
Yes. And IIRC you can also use '#define macro definition'.
Presumably these get fed through to the back-end c-preprocessor?
Presumably. I believe that this is one of those things that GPC inherits from GCC.
Are there any other obscure "features" like this in GPC that I might need to know about?
Many (e.g., I guess you could do something like 'Var x : integer (40)' to declare a 40-bit integer (if such a thing exists) - but I am not sure how it will be handled by the compiler). I am not sure where they are all documented though. I obtain a lot of my information from the GPC source code.
BTW: if anyone is willing to help in completing work on these > >
units, then just drop me a line.
I will be in a position to help, once I have progressed from being a novice GPC user!
Ok. Let me know when you are ready!
Best regards, The Chief ----- Dr Abimbola A Olowofoyeku (The African Chief) Email: African_Chief@bigfoot.com Author of Chief's Installer Pro v5.22 for Win32 http://www.bigfoot.com/~African_Chief/chief32.htm