Recent

Author Topic: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.  (Read 712 times)

440bx

  • Hero Member
  • *****
  • Posts: 2467
{$MODESWITCH NESTEDCOMMENTS OFF} warnings.
« on: May 04, 2021, 09:08:38 pm »
Hello,

When {$MODESWITCH NESTEDCOMMENTS OFF} is enabled and the compiler finds a mistakenly nested comment due to a missing "}" (a simple typo or oversight), the compiler tends to emit a  slew of warnings (usually one per comment line) until it reaches the end of the source file.

my question is: is there a way to tell the compiler to emit an error and stop the compilation at the first nested comment found ? (second unmatched curly brace "{")

Thank you for your help.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9522
  • FPC developer.
Re: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
« Reply #1 on: May 04, 2021, 09:18:40 pm »
Afaik if nested comments are off, you revert to TP comments, where a single closing } closes off multiple {'s.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
« Reply #2 on: May 04, 2021, 09:32:45 pm »
my question is: is there a way to tell the compiler to emit an error and stop the compilation at the first nested comment found ? (second unmatched curly brace "{")

I kind of remember there being an option to "treat warnings as errors" but I can't find it ATM. What I did find is this compiler option (which might be "it"):
Code: [Select]
-Sew : Compiler also halts after warnings
Problem is that it affects *all* warnings and the compiler tends to emit tons of those for almost any non-trivial program %) so it might not be that useful to you if you want only that specific warning to stop compilation.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

440bx

  • Hero Member
  • *****
  • Posts: 2467
Re: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
« Reply #3 on: May 04, 2021, 09:36:24 pm »
Afaik if nested comments are off, you revert to TP comments, where a single closing } closes off multiple {'s.
Thank you marco. When I forget a closing curly brace, I get a sea of warnings about level 2 comments until the compiler reaches the end of the file.

It would be nice if there was a way to tell the compiler to stop whenever a second opening curly brace is found.  That's what I was hoping the modeswitch would do but, it doesn't do that. 

Problem is that it affects *all* warnings and the compiler tends to emit tons of those for almost any non-trivial program %) so it might not be that useful to you if you want only that specific warning to stop compilation.
Thank you lucamar.  Yes, that blanket "warning to error" mode could be "inconvenient". <chuckle>
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

 

TinyPortal © 2005-2018