Andreas K. Foerster wrote:
to further save typing).
It's not for the typing, but the result is much more readable.
Of course. :-)
C is case sensitive, while Pascal is not. So in GPC all Pascal identifiers are converted to lowercase at an early stage, this includes the procedure names. So you have a problem when your C identifiers need uppercase letters. This can only be solved by using an attribute which mentions the name again with its capitalisation: "name 'Example'".
Even when they don't need any uppercase letters, it's recommended to always specify the linker name for external declarations.
I see that there are reasons for the compiler developers. But it is much more convenient for the programmer, if the name would simply be deduced from the Pascal name with its capitalisation, as it is in Free Pascal.
We've discussed this, but using the capitalization from the Pascal identifier would, unfortunately, be wrong because Pascal by definition is case-insensitive, i.e.
procedure Foo; external;
and
procedure foo; external;
are equivalent, i.e. must yield the same result. Of course, FPC doesn't care about standard Pascal, but GPC does (and also applies them, as much as reasonable, to non-standard extensions such as "external").
Well I still have a problem with CString parameters. FPC needs a type cast, while GPC doesn't accept a type cast here. I "solved" it again with "IfDef"s. Does anybody know a better solution?
Perhaps another macro (just a quick idea, as I actually don't like macros too much), that does a type-cast in FPC and nothing in GPC. (Perhaps it could even be a type equal to CString in FPC, though with another name, working as a type-cast by itself, and a nop-macro in GPC.)
Can you tell me more about "nop-macros" in GPC?
{$define foo(X) (X)}
Another macro would even be dirtier than the ifdef.
Somehow yes. But if ifdefs are otherwise required in several places, while a macro has to be defined only once, it might be worth it ...
Frank