[fpc-devel] {$if SizeOf(TMyOrdinalType) = 1} doesn't compile
Michael Van Canneyt
michael at freepascal.org
Sun Jul 18 18:04:10 CEST 2021
On Sun, 18 Jul 2021, Zeljko Avramovic via fpc-devel wrote:
> As discussed at https://forum.lazarus.freepascal.org/index.php/topic,55397.0.html, this compiles and works well:
>
> {$MACRO ON}
> {$if SizeOf(byte) = 1}
> WriteLn('SizeOf(byte) = ', SizeOf(byte));
> {$endif}
>
> however this does not compile:
>
> {$MACRO ON}
> {$define TMyOrdinalType := byte}
> {$if SizeOf(TMyOrdinalType) = 1}
> WriteLn('SizeOf(TMyOrdinalType) = ', SizeOf(TMyOrdinalType));
> {$endif}
>
> and creates this compilation error: Identifier not found "TMyOrdinalType"
>
> Looking at the documentation
> https://www.freepascal.org/docs-html/prog/progsu29.html I was expecting
> {$if SizeOf(TORDINALTYPE) = 1} to compile.
Why are you expecting it ? TOrdinalType is not an identifier.
It's a macro that resolved to an identifier.
Macros are not expanded in directives.
> If I am reading it correctly,
> then I should either file a documentation bug report to make documentation
> more clear, or a feature bug report where this $IF example is not behaving
> as it should. Which should I report?
Documentation bug.
Michael.
More information about the fpc-devel
mailing list