[fpc-devel]defines do not apply to units

Marco van de Voort marcov at stack.nl
Thu Aug 8 02:32:03 CEST 2002


> I am new to FreePascal, so please be tolerant
> if this is a feature, but it looks like a bug to me.

Point taken,
 
> The unexpected behavior is that {$Define Sym}
> statements given in a main program do not stay
> defined for a unit compiled in the same run.

This is normal behaviour, contrary to languages that don't have any scoping
what..so..ever.

The classic workarounds are :

> It is not difficult to work around (include the
> defines file within each unit), but that seems a bit ugly.

1. Indeed, check.

2. Make sure your makefile passes the define to each unit.


Seriously, this is for a reason. With the FPC (and any other Wirthian
(pascal-like)) language with a unit/module system, you can't predict
the exact way the different files/units are compiled, so therefore
defines are restricted to that compilationunit. 

This is the downside of an actual generally postive feature ( the compile
figures the right compilation order, and is generally right about it), with
the above 2 workarounds as an alternative.






More information about the fpc-devel mailing list