[fpc-devel] macro through command line

Dmitry Boyarintsev skalogryz.lists at gmail.com
Mon Jan 18 17:27:35 CET 2016


Hello,

Is it possible to pass a macro through command line (fpc 2.6.4)?
here's an example.
The following code compiles and works as expected:
{$macro on}
{$define A:=5}
begin
  writeln(A);
end.

But, the program
begin
  writeln(A);
end.

fails to compile with the following command line:
fpc -Sm -dA:=5 -va test.pas

The error is
test.pas(2,12) Error: Identifier not found "A"

even though, it seems like -d parameter was handled as it should:
[0.009] Handling option "-Sm"
[0.009] interpreting option "-Sm"
[0.009] Handling option "-dA:=5"
[0.009] interpreting option "-dA:=5"
[0.009] Macro A set to 5

Naturally the actual value (5) is respected by conditional $if statements.

Is not possible to declare a global (or unit-specific) macro from
command-line?
and they have to be declared in the unit interface part?

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.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160118/5ffbd7d6/attachment.html>


More information about the fpc-devel mailing list