[fpc-devel] Use of (* comment for $DEFINEd macros

Paul Robinson paul at paul-robinson.us
Thu Jan 19 20:04:36 CET 2012


- Begin Message From Paul Robinson -
-- First Example --
{$MACRO ON }
{$DEFINE XX1:=' This is from Macro1' }
{$DEFINE XX2:=' This is from Macro2' }
{$DEFINE XX3:=' This is from Macro3' }



{$DEFINE XX1:=' This is from Macro1A' }
{$DEFINE XX2:=' This is from Macro2A' }
{$DEFINE XX3:=' This is from Macro3A' }

Begin
    writeln('*EXAMPLES*');
    Writeln('M1: ', XX1);
    writeln('M2: ', XX2);
    writeln('M3: ', XX3);
    writeln('*END EXAMPLES');
    readln;
end.


*EXAMPLES*
M1:  This is from Macro1A
M2:  This is from Macro2A
M3:  This is from Macro3A
*END EXAMPLES

--- Second Example ---
{$MACRO ON }
{*$DEFINE XX1:=' This is from Macro1' *)
{$DEFINE XX2:=' This is from Macro2' }
{$DEFINE XX3:=' This is from Macro3' }

{$DEFINE XX1:=' This is from Macro1A' }
{$DEFINE XX2:=' This is from Macro2A' }
{$DEFINE XX3:=' This is from Macro3A' }



Begin
    writeln('*EXAMPLES*');
    Writeln('M1: ', XX1);
    writeln('M2: ', XX2);
    writeln('M3: ', XX3);
    writeln('*END EXAMPLES');
    readln;
end.

This returns a compiler error indicating end of file.

--- Third Example ---
{$MACRO ON }
{$DEFINE XX1:=' This is from Macro1' }
{$DEFINE XX2:=' This is from Macro2' }
{$DEFINE XX3:=' This is from Macro3' }

//$DEFINE XX1:=' This is from Macro1A'
{$DEFINE XX2:=' This is from Macro2A' }
{$DEFINE XX3:=' This is from Macro3A' }



Begin
    writeln('*EXAMPLES*');
    Writeln('M1: ', XX1);
    writeln('M2: ', XX2);
    writeln('M3: ', XX3);
    writeln('*END EXAMPLES');
    readln;
end.


*EXAMPLES*
M1:  This is from Macro1
M2:  This is from Macro2A
M3:  This is from Macro3A
*END EXAMPLES


This proves conclusively that only open brace { comment is acceptable for defining macros in Free Pascal.
----
The Lessons of History teach us - if they teach us anything - that no one learns the lessons that history teaches us.
- Message Ends-



More information about the fpc-devel mailing list