<div dir="ltr"><div><div><div><div><div><div><div>Hello,<br><br>Is it possible to pass a macro through command line (fpc 2.6.4)?<br></div>here's an example.<br></div>The following code compiles and works as expected:<br>{$macro on}<br>{$define A:=5}<br>begin<br>  writeln(A);<br>end.<br><br></div>But, the program<br>begin<br>  writeln(A);<br>end.<br><br>fails to compile with the following command line:<br>fpc -Sm -dA:=5 -va test.pas<br><br></div>The error is<br>test.pas(2,12) Error: Identifier not found "A"<br><br></div>even though, it seems like -d parameter was handled as it should:<br>[0.009] Handling option "-Sm"<br>[0.009] interpreting option "-Sm"<br>[0.009] Handling option "-dA:=5"<br>[0.009] interpreting option "-dA:=5"<br>[0.009] Macro A set to 5<br><br></div>Naturally the actual value (5) is respected by conditional $if statements.<br><br></div><div>Is not possible to declare a global (or unit-specific) macro from command-line? <br>and they have to be declared in the unit interface part?<br><br></div><div>The ultimate goal is to actually get a *full path* of a unit during compilation, and I was researching macros as an option to get the information.<br></div><div><br>thanks,<br></div>Dmitry<br><div><div><div><div><br></div></div></div></div></div>