You can add structures to your class and generate code for them.
To do so, add a new class to your model and use the stereotype struct on this class.
If the structure is part of another class, the code for the structure will be written with the code for the file. If the structure is not part of a class, a new file will be generated for the structure.
Then define the members of the structure as attributes:
Unions
(since version 3.2)
To have better support for embedded code generation and support smaller memory footprints we added the union to the Embedded Engineers repository.
You can add a union to your class and generate code for them.
To do so, add a new class to your model and use the stereotype union on this class.
If the union is part of another class, the code for the union will be written with the code for the file. If the union is not part of a class, a new file will be generated for the union.
Nesting
(since version 3.3)
Since C and C++ allow for nesting/embedding Structs and Unions into a single structure we now also support this feature with Embedded Engineer.
To use this feature simple link a union or struct via an Aggregation link its new "Parent" you may also define a name if needed.
Modeled structure | generated code |
---|---|
Example Code Generated typedef struct NestedStructsStruct { union { char Full; struct { byte dd; byte mm; int yyyy; } Date; struct { char B0 : 1; char B1 : 2; }; } Example; } NestedStructs; |
Taken from the CodeGenerationCoponentsTest example for MagicDraw or Enterprise Architect package: Model.EmbeddedEngineer Components.AnsiC.Structural Elements.Structures