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

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Thu Jan 19 21:30:36 CET 2012

Felipe Monteiro de Carvalho wrote:
> On Thu, Jan 19, 2012 at 8:04 PM, Paul Robinson <paul at paul-robinson.us> wrote:
>> --- Second Example ---
>> {$MACRO ON }
>> {*$DEFINE XX1:=' This is from Macro1' *)
> This is wrong code. You cannot open a comment with { and close it with *)
> (* matches *)
> { matches only }
> {* means nothing special, it is a { comment opening followed by a
> character * inside the comment.

I think that was a typo.

program testmacros;

{$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' }

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

0 2>markMLl at pye-dev-01:~$ fpc testmacros
Free Pascal Compiler version 2.7.1 [2011/12/23] for sparc
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for SPARC
Compiling testmacros.pas
testmacros.pas(25) Fatal: Unexpected end of file
Fatal: Compilation aborted
Error: /usr/local/bin/ppcsparc returned an error exitcode (normal if you 
did not specify a source file to be compiled)

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-devel mailing list