Re: [fpc-devel] Compiler bug in macro handling?

2017-04-12 Thread Bernd Oppolzer

No,

if you put a semicolon in there, you will get wrong syntax,
no matter what the datatype is.

Example:

{$MACRO ON}
{$define Fifteen:=15;}
{$define Twelve:=12;}
...
 if HDCOUNT0 >= COUNT0 then X := Fifteen
  else X := Twelve;

will generate this Pascal statement:

 if HDCOUNT0 >= COUNT0 then X := 15;
  else X := 12;

and the semicolon before the else is wrong in Pascal syntax.

Remember: $define (macro processing) is stupid text replacement ...

HTH,

Bernd



Am 12.04.2017 um 20:11 schrieb Giuliano Colla:

Il 12/04/2017 19:51, Michael Van Canneyt ha scritto:

Try removing the semicolon:
{$define Positiva:=False}
{$define Negativa:=True}


Without semicolon it works!

Thanks a lot.

BTW, do you think that this holds true only for the define of boolean 
values?



___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Compiler bug in macro handling?

2017-04-12 Thread Giuliano Colla

Il 12/04/2017 19:54, Bernd Oppolzer ha scritto:

I'm no FPC macro language wizard, but in my believe
you are replacing Positiva with False, followed by a semicolon,
and so you get the error from the compiler.

{$define Positiva:=False}

should probably work.


You are right, I was misled by some examples in the docs, but reading 
more carefully, actually it states that the syntax is


{$define ident:=expr}

so that my semicolon is part of the define, and not a termination as I 
had understood.


Thanks a lot.

Giuliano


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Compiler bug in macro handling?

2017-04-12 Thread Giuliano Colla

Il 12/04/2017 19:51, Michael Van Canneyt ha scritto:

Try removing the semicolon:
{$define Positiva:=False}
{$define Negativa:=True}


Without semicolon it works!

Thanks a lot.

BTW, do you think that this holds true only for the define of boolean 
values?



___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Compiler bug in macro handling?

2017-04-12 Thread Bernd Oppolzer

Hi Guiliano,

I'm no FPC macro language wizard, but in my believe
you are replacing Positiva with False, followed by a semicolon,
and so you get the error from the compiler.

{$define Positiva:=False}

should probably work.

HTH,
kind regards

Bernd


Am 12.04.2017 um 19:39 schrieb Giuliano Colla:

Hi honourable fpc developers!

I found a strange error (both with fpc 2.6.4 and fpc 3.0.0, in Linux 
environment)


The following snippet of code:

{$MACRO ON}
{$define Positiva:=False;}
{$define Negativa:=True;}
...
 if HDCOUNT0 >= COUNT0 then V_PIU0 := Positiva
  else V_PIU0 := Negativa;

 gives rise to a Fatal: syntax error: ";" expected but "ELSE" found.

But if I change the code into:

 if HDCOUNT0 >= COUNT0 then V_PIU0 := False
  else V_PIU0 := True;

 (which IMHO should be identical) it compiles without complaining.

Am I doing something wrong or it is a bug?

Giuliano


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Compiler bug in macro handling?

2017-04-12 Thread Michael Van Canneyt



On Wed, 12 Apr 2017, Giuliano Colla wrote:


Hi honourable fpc developers!

I found a strange error (both with fpc 2.6.4 and fpc 3.0.0, in Linux 
environment)


The following snippet of code:

{$MACRO ON}
{$define Positiva:=False;}
{$define Negativa:=True;}
...
 if HDCOUNT0 >= COUNT0 then V_PIU0 := Positiva
  else V_PIU0 := Negativa;

 gives rise to a Fatal: syntax error: ";" expected but "ELSE" found.

But if I change the code into:

 if HDCOUNT0 >= COUNT0 then V_PIU0 := False
  else V_PIU0 := True;

 (which IMHO should be identical) it compiles without complaining.

Am I doing something wrong or it is a bug?


Try removing the semicolon:
{$define Positiva:=False}
{$define Negativa:=True}

Michael.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


[fpc-devel] Compiler bug in macro handling?

2017-04-12 Thread Giuliano Colla

Hi honourable fpc developers!

I found a strange error (both with fpc 2.6.4 and fpc 3.0.0, in Linux 
environment)


The following snippet of code:

{$MACRO ON}
{$define Positiva:=False;}
{$define Negativa:=True;}
...
 if HDCOUNT0 >= COUNT0 then V_PIU0 := Positiva
  else V_PIU0 := Negativa;

 gives rise to a Fatal: syntax error: ";" expected but "ELSE" found.

But if I change the code into:

 if HDCOUNT0 >= COUNT0 then V_PIU0 := False
  else V_PIU0 := True;

 (which IMHO should be identical) it compiles without complaining.

Am I doing something wrong or it is a bug?

Giuliano


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel