Sparx Systems Forum

Enterprise Architect => Bugs and Issues => Topic started by: et on December 03, 2019, 02:39:13 pm

Title: C++ include guards
Post 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.
Title: Re: C++ include guards
Post by: Eve on December 03, 2019, 04:58:03 pm
I just tried a generation with the default templates and it generated:

Code: [Select]
#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.
Title: Re: C++ include guards
Post by: et on December 04, 2019, 07:50:10 am
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:
Title: Re: C++ include guards
Post by: Eve on December 04, 2019, 08:43:52 am
It's stored in each eap(x) file or database.