On 28 Jan 2011, at 20:49, dib...@wp.pl wrote:

> I'm looking at:
> http://www.freepascal.org/docs-html/prog/progch1.html
> ... and can't find any directive which tell me when I'm compiling a shared 
> library. For example:
> 
> unit1
> 
> {$IFDEF shared_lib}
>  Foo: Integer;
> {$ELSE}
>  Foo: Byte;
> {$ENDIF}
> 
> ....
> 
> I always must remember to add own flag in my projects.

Units are not automatically recompiled by the compiler depending on whether it 
is used by a program or by a shared library. That means that such an ifdef will 
only work if you would always use the -B parameter (which forces the compiler 
to recompile all used units). Therefore adding such a define to the compiler 
will not be done, since it would not have the expected effect in general (most 
people do not compile their code with -B all the time).

What does exist and what can be used is the IsLibrary variable in the system 
unit, which will be true at run time if the current code belongs to a library 
and false if not. It cannot be used in the same situations as an ifdef, but it 
will always work consistently.


Jonas_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to