[fpc-pascal] will be work macro with name of the unit?

Sven Barth pascaldragon at googlemail.com
Wed Jul 15 11:23:58 CEST 2015


Am 15.07.2015 08:21 schrieb "ulrich" <romrum at cbox.cz>:
>
> Hi,
>
> I have this unit, but when I compile it, I get this error:
>
> Illegal unit name XXX_Parser. The unit is saved under dfm_rrparser.pas.
>
> Second question:
>
> Why not displayed $INFO directive in the message window (I have enabled
-vi switch in command line)?
>
>
> {$IFDEF FPC}
>   {$MACRO ON}
>   {$IFNDEF XXX_}
>     {$DEFINE XXX_:=DFM_RR} // replace prefix
>   {$ENDIF}
> {$ENDIF}
>
> {$INFO compiled with XXX_}
>
> unit XXX_parser;
>
> {$mode objfpc}{$H+}
>
> interface
>
> implementation
>
> end.

Macros are only expanded on whole tokens (aka words). So XXX_ is expanded,
but XXX_parser is not. It's the same with C preprocessors by the way.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20150715/bcb56d5b/attachment.html>


More information about the fpc-pascal mailing list