reserved identifier violation
Brought to you by:
kimmov
I suggest to try the search pattern "\<_(?:(?:_(.*))|([A-Z]+))" on source files. A couple of places will be found where names begin with two underscores or an underscore and an uppercase letter.
Examples:
- _ANSI_CONVERT_H_
http://frhed.svn.sourceforge.net/viewvc/frhed/trunk/FRHED/AnsiConvert.h?revision=901&view=markup
- _REGISTRY_H_
http://frhed.svn.sourceforge.net/viewvc/frhed/trunk/FRHED/Registry.h?view=markup&revision=919
This does not fit to the expected naming conventions of the C/C++ language standard.
https://www.securecoding.cert.org/confluence/display/seccode/DCL37-C.+Do+not+use+identifiers+that+are+reserved+for+the+implementation
Thanks for the hint! Do you have maybe also the interest to send us patches for this? :)
How do you think about to make include guards unique?
Would you like to integrate anything from the appended adjustment into your source code repository?
update suggestion
I committed your patch to SVN (In Revision 921)...
Thank you for the bug report and the fix.
Reopen, since there are still some open points.
I am not sure if corresponding adjustments can be achieved for leftovers on this issue after the include guard update.
A few symbols remain which tamper with the reserved name space.
Examples:
- _DEBUG
http://frhed.svn.sourceforge.net/viewvc/frhed/trunk/FRHED/Simparr_imp.h?revision=650&view=markup
http://torjo.blogspot.com/2007/09/ifdef-debug-baaaad-directive.html
- _UNICODE
http://frhed.svn.sourceforge.net/viewvc/frhed/trunk/FRHED/UnicodeString.h?revision=921&view=markup
http://blog.m-ri.de/index.php/2007/05/31/_unicode-versus-unicode-und-so-manches-eigentuemliche/
- _AFX_MINREBUILD
http://frhed.svn.sourceforge.net/viewvc/frhed/trunk/FRHED/Winres.h?revision=4&view=markup
Is a clarification needed for the relationship to the MFC library?
_DEBUG seems to be from the C run-time library:
http://msdn.microsoft.com/en-us/library/0b98s6w8\(v=VS.90).aspx
The same thing seems for the _UNICODE constant.
_AFX_MINREBUILD looks really like something for the MFC libary.
Maybe we should create a list from all remains.
Unfortunately we are working on Microsoft compiler-specific environment and some standards just don't hold in here. One reason is baggage from old versions that must have been kept intact even in latest SDK/compiler versions. One example is _DEBUG and _UNICODE. If you remove _UNICODE you just break Unicode build fatally. _DEBUG is similar thing, MS libraries use it so we must use it.
> _AFX_MINREBUILD
That must be some copy&paste artifact from me messing with that resource file stuff.
Another little comparison might be interesting.
http://stackoverflow.com/questions/2290509/debug-vs-ndebug
What is the point?
Can the symbol "_DEBUG" be replaced by "NDEBUG"?
No.
Then one would need to use negation with it which only makes defines harder to read and understand. For absolute zero gain.
I.e.
#ifndef NDEBUG has double negation
versus
#ifdef _DEBUG is obvious
In former the reader must think "IF NOT DEBUG define is NOT DEFINED". Latter is simple "IF _DEBUG is defined.
I prefer the symbol "NDEBUG" because it is supported by the C standard.
C standard is not C++ standard. This is not standard-coding practice but we need to adapt to the environment we have (MS compiler, MS libraries etc.).
So the
> _AFX_MINREBUILD
is only thing left to fix (_DEBUG and _UNICODE won't be fixed)?
> C standard is not C++ standard. This is not standard-coding practice but we
> need to adapt to the environment we have (MS compiler, MS libraries etc.).
How do you think about the wording on special handling for (leading) underscores in the section "17.6.3.3.2 Global names" of the proposed C++ standard specification?
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3126.pdf
> is only thing left to fix (_DEBUG and _UNICODE won't be fixed)?
It is a matter how far we would like to reduce the dependency on open issues that were introduced by the Microsoft compilation environment.
> > is only thing left to fix (_DEBUG and _UNICODE won't be fixed)?
> It is a matter how far we would like to reduce the dependency on open
> issues that were introduced by the Microsoft compilation environment.
When Frhed can be compiled with other compilers then those are trivial to fix. Until that there is no point in wasting time for that.
Closing.
I just noticed (somehow missed it the one patch was applied). But I really hope this kind of crap doesn't go again into our version control:
-#ifndef _ANSI_CONVERT_H_
-#define _ANSI_CONVERT_H_
+#ifndef FRHED_ANSI_CONVERT_H_04C718D4726843F4AFFCDE8B07EFAEEA
+#define FRHED_ANSI_CONVERT_H_04C718D4726843F4AFFCDE8B07EFAEEA
This is totally pointless change. Only obfuscating the code and meaning of the include guards. We don't have multiple files with same name. And if we had we don't even need to care until we get the compile problems.
I know Visual Studio adds some kind of GUID to the include guard names but I've always hated that. Even if some kids think it is cool it doesn't mean it is needed or wanted.
And, there are thousands of much bigger and more complex projects which don't need that kind of include guard name games. We don't either.
Closing this item now. And closing for comments too.