-d macro value ignored in code
Original Reporter info from Mantis: p_daniel
-
Reporter name:
Original Reporter info from Mantis: p_daniel
- Reporter name:
Description:
Documentation say that {$DEFINE ident:=expr} and command-line -dident:=expr are equivalent, but if you use the second, value of 'ident' available only in compile time expressions and have no effect in code.
For example:
program test;
{$IF DEFINED(MY_VAR)}
{$INFO MY_VAR defined}
{$IF MY_VAR=123}
{$INFO MY_VAR = 123}
{$ELSE}
{$INFO MY_VAR <> 123}
{$ENDIF}
{$ENDIF}
begin
writeln(MY_VAR);
end.
===
fpc test.pas -Sm -dMY_VAR:=123
...
Compiling test.pas
User defined: MY_VAR defined
User defined: MY_VAR = 123
test.pas(15,17) Error: Identifier not found "MY_VAR"
test.pas(17) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
But if you declare {$DEFINE MY_VAR:=123} in code, all is Ok.
Steps to reproduce:
fpc test.pas -Sm -dMY_VAR:=123
Mantis conversion info:
- Mantis ID: 27529
- OS: Linux
- Build: [2014/04/20] for x86_64
- Platform: x86-64
- Version: 2.6.4
- Fixed in version: 3.1.1
- Fixed in revision: 30271 (#3396e2e1)