[fpc-pascal] advanced macros?

Marco van de Voort marcov at stack.nl
Tue Jul 7 14:42:02 CEST 2009


In our previous episode, Roland Schaefer said:
> i.e., passing strings macros for in-macro insertion. Is this true? If
> yes, are there any plans to include such capabilities in the
> preprocessor? It would be very useful in places. On the other hand, the
> mighty preprocessor is one of the primary obfuscation "tools" in C.

It is not that much needed anyway. Generics and inline functions do most of
the stuff that the preprocessor is used for in C. Also the fact that
visibility of identifiers (importing of other compilation units) is not
include based makes it somewhat less useful as many people think.

The only place where I miss it somewhat is in laying out complex structured
constants, preferably in some friendly way. 
 
> One related question: In current FPC macros, can I include {$IFDEF}s? I
> did it, and without using the macro, the unit compiles ok, but I get
> various errors whenever I use the macro.

Not that I know, but you of course can define it under such:

{$ifdef mydef}
 {$define macro:=something}
{$else}
 {$define macro:=something2}
{$endif}

But that is on the place of macro definition, not "local".



More information about the fpc-pascal mailing list