[fpc-pascal] Hack for C-like macro functions — will it work in future?

Sven Barth pascaldragon at googlemail.com
Wed Sep 24 11:17:41 CEST 2014


Am 24.09.2014 10:15 schrieb "Tomas Hajny" <XHajT03 at hajny.biz>:
> However, the trunk compiler offers also another option, although it may or
> may not be usable for you. In particular, take the following:
>
> ---------
> var
>  S2: string;
>
> procedure Log (S: string);
> begin
>  {$IFDEF TEST}
>   WriteLn (S);
>  {$ENDIF TEST}
> end;
>
> begin
>  ReadLn (S2);
>  Log ('Input = ' + S2);
> end.
> =========
>
> If this is compiled with trunk compiler using -OoREMOVEEMPTYPROCS (without
> -dTEST), procedure Log is not called at all and the concatenation of
> strings in its parameter is skipped as well.

Another possibility would be to define Log() as "inline", which should get
rid of the call and maybe the concatenation as well and already works in
2.6.x (though "array of const" would not be supported if needed)

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


More information about the fpc-pascal mailing list