[fpc-pascal] Macro subssystem reworked

Olle Raab olle.r at automagika.se
Mon Jan 10 00:17:38 CET 2005


There has been a major rework of the macro subsystem in free pascal,
to support exportable macros for $mode macpas (see separate mail), and to
make the implementation cleaner.

It is almost transparent, but there might be some subtle effects:

* Macros are now stored in symbol tables like ordinary symbols. There is an
initialmacrosymtable which stores all macros defined by the compiler and
macros on the command line. This table is static and is reused for all files
compiled during a singel invokation of fpc.

* Due to this, -vc will report the definition of initial macros only once.

* Only one $mode directive is allowed. The reason is that, the compiler now
can assume it really knows the mode, when the $mode switch has been
encoutererd. Will give error msg: "Mode switch xxx not allowed here"

* The hints showing the difference between macros defined when a ppu was
compiled and currently defined macros, has been disabled, because it was
buggy and hard to reimplement.


Of course a construct like:

{$IFDEF XXX}
{$MODE FPC}
{$ELSE}
{$MODE OBJFPC}
{$ENDIF}

is allowed since the compiler sees only one $mode.


Info about the implementation:
http://www.freepascal.org/wiki/index.php/Macro_internals


Olle





More information about the fpc-pascal mailing list