Sparx Systems Forum
Enterprise Architect => Bugs and Issues => Topic started by: et on December 03, 2019, 02:39:13 pm
-
I'm new to EA code generation, but was surprised to find that when I generated some C++ code, the include guards on the header files use double underscores, which causes them to generate compiler warnings due to the use of double underscores in identifiers being reserved (this has been a part of the C++ standard since at least 2014). Is there a way to set code generation to not incorporate double underscore in the include guards that I'm not able to find, or how have others been dealing with this?
I'm using EA 13.5.1352.
-
I just tried a generation with the default templates and it generated:
#if !defined(EA_20DC1767_DEDE_46a2_A251_3EDA957EA5AB__INCLUDED_)
#define EA_20DC1767_DEDE_46a2_A251_3EDA957EA5AB__INCLUDED_
I don't get a warning for identifiers with double underscore within the name, but if your compiler is it's coming from line 18 in the C++ File template.
-
Thanks, I found the C++ File Template. Can you clarify if this will be tied to the .eap and/or database if updated, or if it's a per user change?
Also, the ISO/IEC 1488 standard specifies double underscore in identifiers as reserved, so I would imagine that if you enable warnings, compliant compilers should be displeased (as mine is). I would propose that the default template should therefore not be set to use double underscore.
Here are a few references:
- http://www.open-std.org/jtc1/sc22/wg21/docs/standards#14882
- "Each identifier that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use." - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf (linked from the previous link)
- "identifiers with a double underscore anywhere are reserved" - https://en.cppreference.com/w/cpp/language/identifiers
- "Each name that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use." - https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL51-CPP.+Do+not+declare+or+define+a+reserved+identifier
-
It's stored in each eap(x) file or database.