Lazarus

Free Pascal => General => Topic started by: 440bx on May 04, 2021, 09:08:38 pm

Title: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
Post by: 440bx 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.
Title: Re: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
Post by: marcov 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.
Title: Re: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
Post by: lucamar 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.
Title: Re: {$MODESWITCH NESTEDCOMMENTS OFF} warnings.
Post by: 440bx 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>
TinyPortal © 2005-2018