Am 22.06.2018 um 23:10 schrieb Marcos Douglas B. Santos:
On Fri, Jun 22, 2018 at 5:13 PM, Florian Klämpfl <flor...@freepascal.org> wrote:
{$macro on}

{$define TypeStr:=specialize _TypeStr}

begin
   Writeln(TypeStr<TMyRecord>);
end.
Can I use the same idea but for units?

Like this:

{$macro on}

uses
   {$ifdef debug}
     foo_debug
     {$define foo := foo_debug}
   {else}
     foo_run;
     {$define foo := foo_run}
  {$enfif}

begin
   foo.SomeFunc;
end;

Why not simply test it?

That said you can also do this:

=== code begin ===

{$macro on}

{$ifdef debug}
  {$define foo := foo_debug}
{$else}
  {$define foo := foo_run}
{$endif}

uses
  foo;

begin
  foo.SomeFunc;
end.

=== code end ===

Though more often than not such things are done by simply using a different set of units with the same names in a different unit path.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to