Dr A Olowofoyeku wrote:
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.
Yes (though it's not exaclty back-end, but rather a pre-front-end, but that's nitpicking). Since the GCC preprocessor already supports include files and ifdefs (which GPC needs for compatibility to BP and other compilers), it was easiest to just take it and allow the `{$foo}' syntax in addition to `#foo'.
And the additional features (mainly macros) are certainly not a disadvantge ;-). Most uses of macros in C are not necessary in Pascal where we have constants and inline functions(1), and also not recommended in GPC, but there are some situations where they come handy, like the one discussed here.
(1) Yes, modern C compilers have that, too ("enum" and GCC's inline), but C programmers seem reluctant to use them...
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).
That's right, though this feature doesn't come from GCC. (C doesn't have such a feature, except in "struct"s, which sometimes causes C programmers some headaches... ;-)
They are handled mostly like subranges (e.g. Integer (6) = -32 .. 31) and are most often used to get types with a guaranteed size on any system (e.g. for compatibility with other compilers, or binary file compatibility, or when the requirements demand a fixed size, e.g. MD5 values are always 128 bit), since the size of plain `Integer' etc. can vary from system to system.
I am not sure where they are all documented though. I obtain a lot of my information from the GPC source code.
Yes, the GPC documentation is lacking, that's perhaps the most urgent problem. However, the `Integer (40)' feature in particular is documented there under Reference/Integer.
Frank