I have this macro:
{$define TCallback := TCallback2}which gives a long list of these errors.
warning: Expanding of macros exceeds a depth of 16.
What does this warning mean and how can I resolve it?
Regards,
Ryan Joseph

Mailing lists / fpc-pascal / 2022-01
4 messages · 3 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
I have this macro:
{$define TCallback := TCallback2}which gives a long list of these errors.
warning: Expanding of macros exceeds a depth of 16.
What does this warning mean and how can I resolve it?
Regards,
Ryan Joseph
Ryan Joseph via fpc-pascal schrieb am
Mi., 26. Jan. 2022, 03:18:
I did not look at the code, so just a guess: the compiler tries to replace the "TCallback" within the "TCallback2" after it applied the macro leading to add infinitum expansions. This would be wrong, cause the macros should work on whole identifiers and not parts of them...
Regards,
Sven
I have this macro: {$define TCallback := TCallback2} which gives a long list of these…
Hi all,
Le 26/01/2022 à 02:59, Ryan Joseph via fpc-pascal a écrit :
I just tested this:
./test-macro-expansion
TCallBack2 called
cat ./test-macro-expansion.pp
procedure TCallBack2;
begin
writeln('TCallBack2 called');
end;
{$define TCallback := TCallback2}begin
TCallBack();end.
fpc -Sm test-macro-expansion.pp
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64
Compiling test-macro-expansion.pp
Linking test-macro-expansion
12 lines compiled, 0.1 sec
./test-macro-expansion
TCallBack2 called
So it is not as simple as Sven suggested...
Maybe there is another line like
{$define TCallback2 := TCallback}Indeed:
cat ./test-double-macro-expansion.pp
procedure TCallBack2;
begin
writeln('TCallBack2 called');
end;
{$define TCallback := TCallback2}
{$define TCallback2 := TCallback}begin
TCallBack();end.
fpc -Sm ./test-double-macro-expansion.pp
Free Pascal Compiler version 3.2.2 [2021/05/16] for x86_64 Copyright (c) 1993-2021 by Florian Klaempfl and others Target OS: Linux for x86-64
Compiling ./test-double-macro-expansion.pp
test-double-macro-expansion.pp(9,10) Warning: Expanding of macros exceeds a depth of 16. test-double-macro-expansion.pp(9,10) Error: Identifier not found "TCallback" test-double-macro-expansion.pp(14) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: /home/muller/pas/x86_64/fpc-3.2.2/bin/ppcx64 returned an error exitcode
You should probably try to look for another define somewhere else!
Pierre
On Jan 27, 2022, at 12:10 AM, Pierre Muller via fpc-pascal wrote: You should probably try to look for another define somewhere else!
Thanks I found it. The error was misleading as it directed me the first occurrence when it was the second one that did it. I think using undef would have been smart also.
Regards,
Ryan Joseph