unexpected behavior in FPC v3.2.2 lazarus / 64-FPC development ---------------------------------------------------------------------- 440bx · 2024-10-27 07:47 Hello, Consider the following program:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {$define (NoClosingParenthesis}   { no complaint about missing parenthesis    }{$define NoOpeningParenthesis)}   { no complaint about missing parenthesis    }  program _DirectivesParentheses; beginend.                 Note that the compiler directives have mismatched parentheses, yet the compiler compiles that code without complaints. Comments welcome. ---------------------------------------------------------------------- dbannon · 2024-10-27 09:23 Its one or the other of - You have discovered a new compiler directive. The compiler does not check for matching Parenthesis inside a comment. I think I prefer the latter.  A {$define } is a comment when you think about it, a comment left for the compiler rather than a human reader but still a comment. Davo ---------------------------------------------------------------------- MarkMLl · 2024-10-27 09:26 Quote from: dbannon on October 27, 2024, 10:23:12 amIts one or the other of - You have discovered a new compiler directive. The compiler does not check for matching Parenthesis inside a comment. I think I prefer the latter.  A {$define } is a comment when you think about it, a comment left for the compiler rather than a human reader but still a comment. Davo What is the behaviour of the -d option on the commandline (with appropriate shell quoting/escaping)? What is the behaviour of {$ifdef with those mismatched parentheses? Can't check myself, out in a few mins. MarkMLl ---------------------------------------------------------------------- 440bx · 2024-10-27 09:53 Quote from: dbannon on October 27, 2024, 10:23:12 amI think I prefer the latter.  A {$define } is a comment when you think about it, a comment left for the compiler rather than a human reader but still a comment. It's a comment but one that must comply with some rules.  For instance: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifdef (SomeName}  // note the missing closing parenthesisdoes NOT compile because the compiler insists on having a closing parenthesis in that "comment". It was a reasonable thought but, directives are comments that are held to some rules they must follow.  Parentheses must be matched because they cannot be part of the identifier, therefore a lone parenthesis is an extraneous character. ---------------------------------------------------------------------- marcov · 2024-10-27 09:53 IIRC there is a "feature" inherited from turbo pascal that trailing tokens of a $define are ignored. That explains the second one. ---------------------------------------------------------------------- dbannon · 2024-10-27 10:27 Yes Marcov, the trailing Parentheses seems to be ignored, $ifdef finds the identifier both with and without the Parentheses. But the leading Parentheses is a problem. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$define (NoNothing}   {$define NoSomething)}   program _DirectivesParentheses; begin//      {$ifdef (NoNothing}             // This will not compile//      writeln('(NoNothing');//      {$endif}        {$ifdef NoNothing}                      writeln('NoNothing');    // This is NOT printed        {$endif}      {$ifdef NoSomething)}        writeln('NoSomething)');   // This IS printed        {$endif}        {$ifdef NoSomething}        writeln('NoSomething');   // This IS printed        {$endif}end.      You could argue that the way it is here could lead to one of those bugs where we sit and stare at the computer screen, getting angrier by the minute until we spot that leading Parentheses. But I can think of a other things I'd like to see fixed first ! Davo ---------------------------------------------------------------------- Bart · 2024-10-27 21:56 Delphi 7 does not allow the first one, but allows the second one. Bart