Since one of the March 2020 Windows nightly builds - or even earlier -, header guards are automatically added to header files, regardless if there is already one in the header body further down or not. The example below suggests that the algorithm appears to be checking the first line only (try and open the file, then make a change in the editor ... and there is an obsolete additional header guard).
/** comment */
#ifndef HEADER_H_INCLUDED
#define HEADER_H_INCLUDED
#endif // HEADER_H_INCLUDED
Can this feature be switched-off somewhere, since changing to headers of packages with, e.g., a banner before the header guard always results in unneccessary changes which is pretty annoying? Still observed in Nightly build 2020-04-18.
Thanks!
Disable the new header guard plugin
Great - that works! Happy to switch the plugin on again, when it is able to cope with already existing guards.
Many thanks, Miguel!
I'm finding that as of the 11-11-24 nightly build of Code::Blocks, this plugin can still behave badly. One of my old header files had the guard placed after some comment lines and when I opened the file and made an edit in C::B, the plugin added an additional header guard of its own. It refused to stop doing this even when I moved my own header guard to the very top of the file. I also find that it changes the file's line break encoding from CRLF to mixed style when it alters the file. I'm going to just disable the plugin, but it seems to need some fixing.
I would change
if(s.StartsWith(_T("#ifndef")) && ( s.Contains(_T("HEADER")) || s.Right(2).IsSameAs(_T("_H")) || s.Contains(_T(" H_")) || s.Contains(_T("_H_")) || s.Contains(_T("_INCLUDED")) ))
return;
to just
if (s.StartsWith("#ifndef"))
return;
For the EOL part, insertion of '\n' should be replaced by calls to NewLine()