Book a Demo

Author Topic: Problem with Code Generation for C  (Read 3034 times)

Heverhagen

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Problem with Code Generation for C
« on: July 08, 2009, 09:18:14 pm »
When generating code for C (no oo support), a public attribute of a class is generated into the header file like this:
header file:
int attr1;

This makes no sense in our opinion. We would prefer the following solution:
header file:
extern int attr1;

source file:
int attr1;

If we change the generated code manually and synchronize it back with the model, we get two attributes. One with private scope and one with public scope, but both with the same name. This would be OK, but, after the next forward generation from model into code, the declaration within the source file is deleted by EA.

So we decided to change the code generation templates. The result was, that, if we replace the generated source files (F11 with advanced option "replace existing source file") everything works fine. If we do not replace existing source files (F11 with advanced option "Always synchronize with existing file") our changed code generation templates seem not to be used by EA. Again, the declaration within the source file is deleted by EA.

Is there any solution or workaround for this problem?

Thanks in advance
regards
Torsten

SimonZ

  • EA Administrator
  • EA Novice
  • *****
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Problem with Code Generation for C
« Reply #1 on: July 14, 2009, 10:42:29 am »
As far as I know, there is no workaround for this problem.

EA didn't consider the case of two Attributes with same name but different Scope.

You may need to send a feature request to Sparx Systems.

Heverhagen

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Problem with Code Generation for C
« Reply #2 on: July 23, 2009, 07:16:48 pm »
Hello Simon,

the question is, how to generate and synchronise code for public variables in C.
EA produces two Attributes with same name but different Scope when synchronizing from code like:
header file:
extern int attr1;

source file:
int attr1;

The header file contains only the declaration of the variable (extern). The source file contains the definition.
I think, EA can't deal with public variables in C.

regards,
Torsten