Closed jdlugosz closed 3 years ago
@jdlugosz Hello.
I need more information to understand what issue is. I'm confused now. Please describe with code samples and your suggestion about it.
Names containing two consecutive underscores, or beginning with an underscore followed by a capital letter, are reserved for use by the implementation.
In short, it is exactly wrong to imitate the guards you see in the standard library files.
Your sample animation shows the example of __TEST_H__
which is a reserved name. For all you know, some standard header defines a macro by that name for its own use, or worse.
@jdlugosz You can change default config to remove underscores from header guards like this.
"CppHelper.HeaderGuardPattern": "{FILE}_H"
or
"CppHelper.HeaderGuardPattern": "GUARD_{FILE}_H"
But the default shouldn't use reserved names.
When generating an include guard, don't use a name that's reserved for the implementation. Mimicing what is seen in the standard headers is a common mistake, and one reason for using an automated tool is to always get it right.