Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: johnw@wessex on February 08, 2005, 06:26:40 am
-
I'm trying out the demo of Enterprise Architect.
I created a class diagram containing a private static integer variable and then generated the C++ source code.
///////////////////////////////////////////////////////////
// Class1.h
// Implementation of the Class Class1
// Created on: 08-Feb-2005 09:39:27
///////////////////////////////////////////////////////////
#if !defined(EA_CF70D464_4571_408e_AD98_FC90F6E31E1F__INCLUDED_)
#define EA_CF70D464_4571_408e_AD98_FC90F6E31E1F__INCLUDED_
class Class1
{
public:
Class1();
virtual ~Class1();
private:
static int some_variable;
};
#endif // !defined(EA_CF70D464_4571_408e_AD98_FC90F6E31E1F__INCLUDED_)
///////////////////////////////////////////////////////////
// Class1.cpp
// Implementation of the Class Class1
// Created on: 08-Feb-2005 09:39:27
///////////////////////////////////////////////////////////
#include "Class1.h"
//**** THIS LINE IS MISSING FROM THE GENERATED SOURCE ****
int Class1::some_variable;
//*************************************************
Class1::Class1(){
}
Class1::~Class1(){
}
Without the missing line the code is un-compileable!
Any thoughts?
-
What do you mean by un-compilable? Why are you missing this line? Did you include this attribute in Class1 and it's not generated?
-
What do you mean by un-compilable?
A static variable declared in a class must be defined.
class MyClass
{
public:
static int var;
};
int MyClass::var;
Did you include this attribute in Class1 and it's not generated?
Correct
-
Appearently it is a known issue and you must import this XML for it to work.
<?xml version="1.0" encoding="windows-1252" ?>
- <RefData version="1.0" exporter="EA.25">
- <DataSet name="C++_Code_Template" table="t_template" filter="TemplateType='#TemplateType#' and TemplateName='#TemplateName#' and Style='#Style#'">
- <DataRow>
<Column name="TemplateID" value="{A67D5899-C97E-4286-93AC-716A45218004}" />
<Column name="TemplateType" value="C++_Code_Template" />
<Column name="TemplateName" value="Attribute__StaticImpl" />
<Column name="Template" value="%attType% %className%::%attName%%attInitial ? " = " value%;" />
</DataRow>
- <DataRow>
<Column name="TemplateID" value="{FD32BDFD-B7DD-4e8d-9D6B-E42831FF392C}" />
<Column name="TemplateType" value="C++_Code_Template" />
<Column name="TemplateName" value="Class Body Impl" />
<Column name="Template" value="$templateArgs=%list="ClassParameter" @separator=", "% %if $templateArgs != ""% $templateArgs="<" + $templateArgs + ">" $templ="template" + $templateArgs %endIf% $consPrefix=$templ + "\n" + %classQualName% + "::" %PI="\n\n\n"% %list="Attribute__StaticImpl" @separator="\n\n" attStatic=="T"% %if genOptGenConstructor == "T" and genOptGenConstructorInline != "T" and classHasConstructor != "T"% $consPrefix%className%(){\n\n} %endIf% %if genOptGenDestructor == "T" and genOptGenDestructorInline != "T" and classHasDestructor != "T"% $destructor=$consPrefix+"~"+%className%+"(){\n\n}" $destructor %endIf% %if genOptGenCopyConstructor == "T" and genOptGenCopyConstructorInline != "T" and classHasCopyConstructor != "T"% $consPrefix%className%(const %className%& the%className%){\n\n} %endIf% %list="OperationImpl" @separator="\n\n\n"% %list="InnerClassImpl" @separator=""%" />
</DataRow>
</DataSet>
</RefData>