Glossary
| Acronym | Definition |
|---|---|
| SPO | Software Production Operation |
| BL | Behavior Layer |
| ML | Middleware Layer |
| BSM | Behavior Specific Middleware |
| TSM | Target Specific Middleware |
Glossary
Referenced Documents
General Concepts
UML class code generation is part of the components generation as presented in [1] is invoked during execution of UML to C operation as presented in [3] This document focuses on the C code generation for the class model. In addition of this general introduction, it is important to remind that the C code generator generates C code from UML classes. UML classes are dedicated to object-oriented programming – OOP - which is not the case of the C language. The concepts of OOP are the following ones:
Generated C code supports the concepts of the object-oriented programming using a specific implementation such as: EncapsulationA structure is created for the class. Properties are part of the structure. Operations are declared as follows: All functions have a prefix with the name of the class and take as the first parameter a pointer to the structure representing the class. ![]() AbstractionAbstraction is possible by hiding some private operations using the keyword static of C. On the opposite, protected operations cannot be hidden and the visibility of properties cannot be controlled. Nevertheless, documentation is inserted to inform of the visibility of a member. InheritanceIn case of inheritance, a variable representing the inherited class is inserted in the structure of the class. In addition, constructors are generated and called to instantiate each element. Here is an example of a class Rectangle, which inherits from a class Shape. ![]() ![]() PolymorphismPolymorphism is supported using a mechanism of virtual table. Supported ElementsHere is an exhaustive list of elements used by the code generator to produce the code with a summary of the purpose and impact.
Code Generator Specification
This section is divided in 2 parts:
Files Specifications
Generated code class elements are composed of two files for each class:
General requirements related to file content are described in [2]. <ClassName>.h
<ClassName>.h header file describes the content of a class entity. This file declares all the elements associated with a class. File <ClassName>.h is generated for each UML class element involved in the code generation. A macro is generated to read the content of the file as a C declaration if it is included directly or indirectly from a C++ file. Rationale: During compilation, information of this file must be treated as C information.
/* Macro to prevent error if file is included from a Cpp file */
#ifdef __cplusplus
extern "C" {
#endif
Example: Cpp macro #include to the file <Top_ClassName>_types.h is generated for the selected UML also known as top class. Requirement not supported – ZA7 <Top_ClassName>_types.h file contains the types used at interface with top UML class. #include to the file internal_types.h is generated. internal_types.h file contains the types used in the selected UML class and its subelements.
For every other type the current class depends on — through
inheritance, composition, aggregation, association or usage —
the header generates either an
Every type that is only announced in the header is included in the corresponding implementation file, so the generated code never depends on an indirect inclusion to compile. A user-specific section is generated to give the opportunity to insert additional includes /********************************************************************** * Includes declaration **********************************************************************/ #include "LockManager_internal_types.h" #include "LockableElement.h" /* BEG_USER_CODE(header) do not remove */ /* Add your includes here */ /* END_USER_CODE(header) do not remove */ Example: Includes section See chapter 9.2 for more details. Note that namespace that is a CPP concept is not supported by the C code generation.
A forward declaration of the struct is generated prior to
structures definition. The forward declarations are grouped in a
single section, after every A structure identified as a virtual table is generated to contain the function pointers for each operation of the class. The virtual table enables the implementation of interfaces and the generalization of classes. Declaration is done in section VIRTUAL TABLE MEMBERS SECTION. To get more information on the declaration, see the dedicated section in chapter 9.2. If the Memory Optimization option is set to Prefer ROM, a const structure is generated containing the const variables generated from properties declared as read-only and the const variables generated from relations with a fixed multiplicity. The const structure enables the declaration of const elements in the ROM section to reduce RAM consumption. If Memory Optimization option is set to Prefer ROM, the 3 first fields of the const structure are:
Const properties are generated in the const struct definition in CONST HEADER MEMBERS SECTION. To get more information on the declaration, see the dedicated section in chapter 9.2. The class is represented by a structure. The structure is declared using the regular c declaration mechanism. To get more information on the declaration, see the dedicated section in chapter 9.2. If the Memory Optimization option is set to none, the 2 first fields of the structure are:
If the Memory Optimization option is set to Prefer ROM, the first field of the structure are:
To get more information on the declaration, see the dedicated section in chapter 9.2. Properties are generated in the struct definition in HEADER VARIABLE MEMBERS SECTION and HEADER CONST MEMBERS SECTION. To get more information on the declaration, see the dedicated section in chapter 9.2. The Operations are generated as functions following the struct definition in FUNCTIONS DECLARATION SECTION. To get more information on the declaration, see the dedicated section in chapter 9.2. In addition of the attributes declared in the class, the struct must contain extra sections depending on the model. Extra Sections - Constraint Block Parameters SectionIn the context of a SysML Constraint Block, a variable is generated for each parameter of each constraint block. Extra Sections - Communication Interface SectionIf the class contains ports or behaviors scheduled by a ExecutionType, an extra variable referencing the interface part of the class is generated. If the Memory Optimization option is set to Prefer ROM, this section is declared in const structure, in the regular structure otherwise. Extra Sections - Shared Variables Declaration<Class name>.c<ClassName>.c source file implements functions declared in the corresponding header file for a class. File <ClassName>.c is generated for each UML class element involved in the code generation. #include to the header file of the corresponding class is inserted. A user-specific section is generated to give the opportunity to insert additional includes. /********************************************************************** * Includes declaration **********************************************************************/ #include "VehicleDoorsManager.h" #include "LockableElement.h" /* BEG_USER_CODE(header) do not remove */ /* Add your includes here */ /* END_USER_CODE(header) do not remove */ Example: Include to header of class. Default destructor is declared as static and a defined in the local members declaration. Protected and private functions are declared as static and a defined in the local members declaration. The content of this section is described in chapter 9.2.
A const variable named
/**********************************************************************
* Local Members Declaration
**********************************************************************/
/**
* Destructor declaration
* Generated automatically
* @generated_from _2022x_16600ad_1673889073704_233637_17321
* @reverse_ignore
*/
static void LockableElement_dtor(struct LockableElement_* self);
<PROTECTED AND PRIVATE FUNCTIONS SECTION – See chapter 9.2>
/** vtable variable declaration */
const LockableElement_vtable LockableElement_vt = {
<VIRTUAL TABLE MEMBERS INITIALIZATION – See chapter 9.2>
};
A section CLASS OPERATION IMPLEMENTATION containing implemented of class operations is inserted. The content of this section is described in chapter 9.2. /********************************************************************** * Functions Implementation **********************************************************************/ <IMPLEMENTATION MEMBERS SECTION – See chapter 9.2> Example: Class implementation internal_types.hThe internal_type.h file describes the data types used by the properties and the operations in the model. File internal_types.h is generated for the input element that is a class. General requirements related to file content and structure are described in [2]. #include to the file stdbool_itf.h is generated. The stdbool.h file defines bool. Each type used by at interface level class is generated. See chapter 9.2 for more details depending on the elements. #include \<stdbool.h\> \<DATA TYPES DECLARATION -- See chapter 9.2\> Example: Data types declaration Based on the dependency between types, each type referencing another type is defined after this type. Each type definition is protected by a #ifdef, #define, #endif mechanism. Each type is defined by the C typedef mechanism. /********************************************************************** * Data Type <type> definition * @generated_from <uuid> **********************************************************************/ #ifndef <type>_DEFINITION #define <type>_DEFINITION typedef <base_type> <type>; #endif Example: Type declaration Semantic Code Specifications
This section describes the behavior of the code generator depending on the UML element. Package with C++ Namespace StereotypeThe concept of namespace is not supported by C code generator. The stereotype C++ namespace is not used by the C code generator. ClassHEADER VARIABLE MEMBERS SECTION and HEADER CONST MEMBERS SECTIONA class is translated into several structures containing fields and operations pointers corresponding to the properties and operations of the class and a list of functions declared outside the structure. Refer to chapter <ClassName>.h for more details. If a generalization relation is created from a class to another one, this inheritance relation is reproduced by declaring an instance of the inherited class into the structure of the class source of this generalization relation. ![]() The visibility is not a concept supported with C code generation. This concept is used for documentation purpose. The visibility level is printed in the comment above the variable declaration. REQ NOT YET SUPPORTED
/** @generated from: <class uuid> */
typedef struct A {
/**
* @brief Public Inheritance realization to class B
* @generated_from _2022x_16600ad_1673889073704_233637_17321
*/
B extended_class_B;
}A;
Example: Class declaration with generalization If the class uses the stereotype C++Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)).
/** @generated from: <class uuid> */
struct __attribute__((packed)) A {
};
Example: Class declaration with packed If a class uses the stereotype C++Aligned, and the alignment attribute is set to a valid value, and the compiler parameter is set to gcc, the generated code must include the keyword __attribute__((aligned({alignment}))).
struct __attribute__((aligned({alignment}))) A {
};
Example: Class declaration using aligned A valid value for alignment is an integer that is a power of two. Nested ClassNested class is not supported. A declaration of a class/struct or union can appear within another class. Such declaration declares a nested class. https://en.cppreference.com/w/cpp/language/nested_types Abstract ClassA class is abstract when all functions are defined as virtual. See virtual operation. Friend ClassThe concept of Friend class is not supported by the C code generator. The usage of a relation applying the C++ Friend stereotype is not supported. Global Functions and Variables![]() Global functions and variables are declared using an unnamed class with C++Global stereotype. Global functions and variables are mapped to operations and attributes into an unnamed class with the stereotype «C++Global». The generated files are named global.cpp and global.h. Properties declared in the global class are declared directly in the file without structure. Operations declared in the global class are declared directly in the file. Operations declared in the global class are declared without the extra argument self like other operations that belong to a standard class. If a global variable uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the alignment attribute is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))).
int __attribute__((aligned({alignment}))) myGlobalVariable
Example: Global variable declaration using aligned
int* __attribute__((aligned({alignment}))) myGlobalVariable
Example: Global pointer declaration using aligned A valid value for alignment is an integer that is a power of two. If a global variable uses the stereotype C++Aligned, and the selected C version is greater than or equal to C23, and the alignment attribute is set to a valid value, the generated code must include the keyword alignas({alignment}).
alignas({alignment}) int myGlobalVariable
Example: Global variable declaration using alignas A valid value for alignment is an integer that is a power of two. The keywords alignas({alignment}) and __attribute__((packed)) cannot be applied simultaneously to the same type or variable. When both are defined, the generated code must use alignas({alignment}) and omit __attribute__((packed)). Composition Relation – Black DiamondHEADER CONST MEMBERS SECTIONif a composition relation is created from a class to another one with a multiplicity 1, a variable is created in the structure of the source class of relation to point to the target class in the const members section part. if a composition relation is created from a class to another one as not directional, a pointer variable is created in the structure of the target class of relation to point to the source class in the const members section part. Compositions that are not directional are not supported because of a compilation error and cyclic dependency. ![]()
typedef struct A {
/**
* @brief Public attribute for composition relation to B:b
* @generated from: _2022x_16600ad_1674047956690_871296_20640
*/
struct B b;
}A;
Example: Variable in source class
typedef struct B {
/**
* @brief Public attribute for associationrelation to A:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
struct A *a;
}B;
Example: Variable in target class for not directional relation if a composition relation is created from a class to another one with a multiplicity fixed and greater than 1, an array of variables is created in the structure of the source class of relation to point to the target class with the size equal to the multiplicity in the const members section part.
typedef struct A {
/**
* @brief Public attribute for composition relation to array<B,2>:b
* @generated from: _2022x_16600ad_1674047956690_871296_20640
*/
struct B b[2];
}A;
Example: Composition with a multiplicity of 2 Relations with a multiplicity * are not supported. HEADER VARIABLE MEMBERS SECTIONif a composition relation is created from a class to another one with a variable multiplicity between 2 values and upper multiplicity greater than 1, an array of variables is created in the structure of the source class of relation to point to the target class with the size equal to the multiplicity in the variable section part. Relations with a multiplicity * are not supported. Aggregation Relation – White DiamondHEADER CONST MEMBERS SECTIONif an aggregation relation is created from a class to another one with a multiplicity 1, a pointer variable is created in the structure of the source class of relation to point to the target class in the const members section part. if an aggregation relation is created from a class to another one as not directional, a pointer variable is created in the structure of the target class of relation to point to the source class. ![]()
typedef struct A {
/**
* @brief Public attribute for aggregation relation to B:b
* @generated from: _2022x_16600ad_1677666453655_544305_17510
*/
struc B *b;
}A;
Example: Variable in source class
typedef struct B {
/**
* @brief Public attribute for aggregation relation to A:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
struct A *a;
}B;
Example: Variable in target class for not directional relation If an aggregation relation is created from a class to another one with a multiplicity fixed and greater than 1, an array of pointers is created in the structure of the source class of relation to point to the target class with the size equal to the multiplicity in the const members section part.
typedef struct A {
/**
* @brief Public attribute for aggregation relation to array<B,2>:b
* @generated from: _2022x_16600ad_1677666453655_544305_17510
*/
struct B *b[2];
}A;
Example: Aggregation with a multiplicity of 2 Relations with a multiplicity * are not supported. HEADER VARIABLE MEMBERS SECTIONIf an aggregation relation is created from a class to another one with a variable multiplicity between 2 values and upper multiplicity greater than 1, an array of pointers is created in the structure of the source class of relation to point to the target class with the size equal to the multiplicity in the const members section part. Relations with a multiplicity * are not supported. Association RelationHEADER CONST MEMBERS SECTIONIf an association relation exists between two classes with a multiplicity 1, a pointer variable is created in each class to point to the other class. ![]()
typedef struct A {
/**
* @brief Public attribute for associationrelation to B:b
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
struct B *b;
}A;
typedef struct B {
/**
* @brief Public attribute for associationrelation to A:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
struct A *a;
}B;
Example: Association between 2 classes if an association relation exists between 2 classes with a multiplicity fixed and greater than 1, an array of pointer is created in each class to point to the other class with the size equal to the multiplicity.
typedef struct A {
/**
* @brief Public attribute for associationrelation to array<B,2>:b
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
struct B *b[2];
}A;
typedef struct B {
/**
* @brief Public attribute for association relation to array<A,2>:a
* @generated from: _2022x_16600ad_1677666453655_204390_17509
*/
struct A *a[2];
}B;
Example: Association between two classes with a multiplicity of 2 in both directions Relations with a multiplicity * are not supported. HEADER VARIABLE MEMBERS SECTIONif an association relation exists between 2 classes with a variable multiplicity and upper multiplicity greater than 1, an array of pointer is created in each class to point to the other class with the size equal to the multiplicity. Relations with a multiplicity * are not supported. Usage relationA usage relation is used to declare that a class usage another element. It is translated into an include of the element in the generated code. A usage relation can be used from a class to an interface or another class. If a class declares a usage relation to another entity, the corresponding #include is generated. For class object, the generated #include in the context of a usage relation is generated by adding automatically the suffix .h if the name of the element does not contain a suffix. For interface object, the generated #include in the context of a usage relation is generated using the name of the interface. If the C++ Include stereotype applied on the usage relation carries the value Class Forward, a forward declaration of the used struct is generated in the header instead of an #include, and the #include is generated in the implementation file. The value None generates neither. If no C++ Include stereotype is applied on the usage relation, the generated #include is generated as a system include using <>. If a C++ Include stereotype is applied on the usage relation, it is possible to generate a user include using “” or a system include using <>. REQ NOT SUPPORTED ![]() For optimization reasons, two new stereotypes are proposed as replacement of C++Include: “C++ Location“ stereotype applies on usage relation. It supersedes use of “C++ Include“ stereotype. It helps to specify whether used element is targeted for source header or implementation. “C++ Kind“ stereotype applies on UML artifact. It supersedes information eventually set in “C++ Include“ stereotype. Example: artifact with “C++IncludeKind“ set to System in Class.h #include <Artifact.h> Example: artifact with “C++IncludeKind“ set to User in Class.h #include "Artifact.h" Example: usage relation with “C++Location“ set to Header in Class.h #include "UsedClass.h" Example: usage relation with “C++Location“ set to Implementation in Class.c #include "UsedClass.h" Interface Realization
Interface realization enables a class to realize one or several interfaces. An interface is an abstract class whose operations are realized by the implementing class. Polymorphism is supported through a mechanism of virtual table: each interface and each class owns its own virtual table. A class realizing an interface is connected to the interface virtual table through dedicated thunk functions, so an object can be substituted by another one as soon as they share the same interface. A class can realize multiple interfaces. The same mechanism is used to realize an interface and to specialize a class through a generalization relation. HEADER VARIABLE MEMBERS SECTIONA file named <interface name>.h is generated for each realized interface and the corresponding #include is generated in the implementing class header file.
For each realized interface, a variable typed with the
interface structure and named
/** @generated_from _2024x_3_1ca00d3_1747908200222_116813_4036 */
typedef struct ParentClass_ {
/** Pointer to virtual table */
const ParentClass_vtable *vtable;
/** Function pointer to destructor function generated automatically */
void (*dtor)(struct ParentClass_*);
/** @generated_from _2024x_3_1ca00d3_1747908200223_308090_4038 */
AnIfc extended_class_AnIfc;
/** @generated_from _2024x_3_1ca00d3_1747908200224_329975_4039 */
AnotherIfc extended_class_AnotherIfc;
} ParentClass;
Example: Class realizing two interfaces AnIfc and AnotherIfc VIRTUAL TABLE MEMBERS INITIALIZATION SECTION
For each realized interface, a dedicated virtual table named
For each operation of a realized interface that is realized by the implementing class (i.e. an operation with the same signature), the dedicated virtual table is initialized with the corresponding thunk function (see below).
/** vtable variable declaration */
const ParentClass_vtable ParentClass_vt = {
ParentClass_myOp2,
ParentClass_myOp,
};
/** vtable declaration for extended class AnIfc */
const AnIfc_vtable ParentClass_as_AnIfc_vt = {
.myOp2 = ParentClass_as_AnIfc_myOp2_thunk,
};
/** vtable declaration for extended class AnotherIfc */
const AnotherIfc_vtable ParentClass_as_AnotherIfc_vt = {
.myOp = ParentClass_as_AnotherIfc_myOp_thunk,
};
Example: Class virtual table and one dedicated virtual table per realized interface IMPLEMENTATION MEMBERS SECTION
For each operation of a realized interface that is realized by
the implementing class, a thunk function named
A thunk function receives a pointer to the realized interface
structure, recovers the pointer to the implementing class
structure using the
/**
* Thunk function connecting extended_class_AnIfc::myOp2 -> ParentClass::myOp2
* @generated_from _2024x_3_1ca00d3_1747908200231_870497_4049
*/
void ParentClass_as_AnIfc_myOp2_thunk(struct AnIfc_* self){
ParentClass *clsPtr = (ParentClass*)((char*)self - offsetof(ParentClass, extended_class_AnIfc));
ParentClass_myOp2(clsPtr);
}
/**
* Thunk function connecting extended_class_AnotherIfc::myOp -> ParentClass::myOp
* @generated_from _2024x_3_1ca00d3_1747908200231_326294_4050
*/
void ParentClass_as_AnotherIfc_myOp_thunk(struct AnotherIfc_* self, const Integer /*in*/ param){
ParentClass *clsPtr = (ParentClass*)((char*)self - offsetof(ParentClass, extended_class_AnotherIfc));
ParentClass_myOp(clsPtr, param);
}
Example: Thunk functions delegating realized interface operations to the implementing class Constructor
For each realized interface, the constructor of the
implementing class calls the constructor of the embedded
interface variable
void InterfaceRealizationTestClass_ctor(InterfaceRealizationTestClass* self) {
/* Init pointer to destructor */
self->dtor = &InterfaceRealizationTestClass_dtor;
/* Init pointer to virtual table */
self->vtable = &InterfaceRealizationTestClass_vt;
/* Call extended class ParentClass constructor */
ParentClass_ctor(&self->extended_class_ParentClass);
}
Example: Constructor initializing the embedded realized interface PropertyHEADER VARIABLE MEMBERS SECTION
Each property declared in a UML class is replicated in the generated code in the structure of the class except for const variables. ![]() A brief description is generated for any property describing the type and name of the variable. Additional documentation is generated if the documentation section is a field in the model. Type of the property is used as declared in the model. The visibility is not a concept supported with C code generation. This concept is used for documentation purpose. The visibility level is printed in the comment above the variable declaration. Visibility of the property is used as declared in the model. /** * @brief Public attribute for composition relation to LockEnum:lockStatus * This is my documentation for LockControl * @generated_from _19_0_3_16600ad_1654594678283_920922_43338 */ LockEnum lockStatus; Example: Property declaration Pointer DeclarationIf a type modifier * is defined for a property, it is used to declare a pointer to a variable. /** @generated_from _2022x_16600ad_1673889212530_542477_17485 */ Boolean *LockStatus; Example: Pointer List DeclarationThe concept of List is not supported by the C code generator. Array Declaration![]() if the property applies the stereotype C++ Attributes and array value is configured, variable is generated as an array<Variable Type, length>. /** * @brief Public attribute array<Boolean,3>:LockStatus * @generated_from _2022x_16600ad_1673889212530_542477_17485 */ Boolean LockStatus[3]; Example: Array declaration MutableThe concept of Mutable is not supported by C code generator. Bit FieldThe concept of bit field is not supported by the C code generator. Extern- VolatileThe concept of volatile is not supported by the C code generator. CLASS OPERATION IMPLEMENTATIONDefault value is defined in the constructor of the structure as it is impossible to define default value to struct members in C. HEADER CONST MEMBERS SECTIONConstIf the isReadOnly attribute of the property is set to true, the variable is declared as const in the CONST MEMBERS section. /** * @brief Attribute Boolean:debugMode * @generated_from _2022x_2_1ca00d3_1686732945801_136413_17517 */ const Boolean debugMode; Example: Const declaration PackedIf the property uses the stereotype C++Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)), except for bitfield, pointer and reference properties.
typedef struct ClassWithAttrPacked_ {
* @brief <brief description>
* @generated_from <class uuid>
*/
int __attribute__((packed)) attributePacked;
} ClassPacked;
Example: Property declaration with packed AlignedIf the property uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the selected C version is not greater than or equal to C23, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))).
typedef struct ClassWithAttrAligned_ {
int __attribute__((aligned({alignment}))) attributeAligned;
struct MyType* __attribute__((aligned({alignment}))) x;
} ClassAligned;
Example: Property declaration using alignment A valid value for alignment is an integer that is a power of two. If the property uses the stereotype C++Aligned, and the selected C version is greater than or equal to C23, and the attribute alignment is set to a valid value, the generated code must include the keyword alignas({alignment}) except for bitfield and reference properties.
typedef struct ClassWithAttrAligned_ {
alignas({alignment}) int myProperty1;
alignas({alignment}) int *myProperty2;
} ClassAligned;
Example: Property declaration using alignas A valid value for alignment is an integer that is a power of two. The keywords alignas({alignment}) and __attribute__((packed)) cannot be applied simultaneously to the same type or variable. When both are defined, the generated code must use alignas({alignment}) and omit __attribute__((packed)). OperationFUNCTIONS DECLARATION SECTION![]() Each operation declared as public in a UML Class is declared in the header file after the structure representing the class object. Each operation is declared with a prefix having the name of the class object followed by an underscore. Each operation with the parameter isStatic set to false or not set is declared with a first parameter, which is a pointer to the structure as the first argument. A brief description is generated for any property describing the type and name of the variable. Additional documentation is generated if the documentation section is filled in the model. Visibility is displayed in the comment associated with the operation as declared in the model. /** * @brief Public operation LockableElement_lockDoors * @generated_from _2022x_16600ad_1673944282153_805594_18447 */ Boolean LockableElement_lockDoors(struct LockableElement* self); Example: Operation declaration ConstructorIf an operation uses the stereotype C++ Constructor, the function is declared as a constructor in the header file. Default constructor is automatically generated for class object even if not declared in the class. This constructor is generated with the suffix _ctor. Constructor parameters are automatically calculated to enable the initialization of members if required. A constructor defined in a class is declared with a specific suffix _user_ctor to distinguish this constructor from the ones that are automatically generated. /** * @brief Public constructor * @generated_from _2022x_16600ad_1677492413311_524708_17320 */ void LockableElement_user_ctor(LockableElement* self); Example: Constructor declaration If a class contains association relations, a default constructor is generated for each relation with an argument for the corresponding association relation as pointer to the destination of the association. The name of the constructor contains the name of the association to distinguish it. If a class contains aggregation relations, the default constructor is generated with an argument for each aggregation relation as a pointer to the destination of the aggregation. Default constructor is generated with the arguments for associations followed by arguments for aggregations. /** * @brief Public constructor * @generated_from _2022x_16600ad_1677492413311_524708_17320 */ void Root_associated_ctor(Root* self, struct Asso * asso, struct Aggreg_* aggreg; Example: Default constructor with an association and an aggregation Explicit ConstructorThe concept of explicit constructor is not supported by the C code generator. DestructorA default destructor is automatically generated for a class object even if not declared in the class. This destructor is represented as a function pointer in the structure. The constructor is positioned as the first attribute of the structure.
/** @generated from: <class uuid> */
typedef struct A {
/**
* Function pointer to destructor function generated automatically
*/
void (*dtor)(struct LockableElement*);
}A;
If an operation uses the stereotype C++ Destructor, the function is declared as a destructor in the header file. – Not supported – add a rule. Getter / setterGetter/setter can be configured by the context menu: ![]() ![]() Getter and setter are declared in the header file for each function declared accordingly in the model. /** * @brief Setter method for attribute WindowPosition * this is an example of documentation from model * @generated from: _2022x_16600ad_1677147742721_382790_17804 */ void Door_setWindowPosition(Door* self, ControlEnum /*in*/ windowPosition); /** * @brief Getter method for attribute WindowPosition * @generated from: _2022x_16600ad_1677147745041_9971_17808 */ ControlEnum Door_getWindowPosition(Door* self); Example: Getter and setter InlineIf an operation uses the stereotype C++ operation and the attribute Inline is set to true, the function is generated as an inline function. /** * @brief Public operation isLocked * @generated_from _2022x_16600ad_1677575910398_769750_17568 */ inline bool LockableElement_isLocked(LockableElement* self); Example: Inline VirtualIf an operation uses the stereotype C++ operation and the attribute Virtual is set to true, the function is generated as a pure virtual function. Virtual function is not yet supported. The concept of Volatile is not supported by the C code generator. StaticIf the attribute isStatic is set to true for an operation, the first argument of the operation is not generated. (On opposite of REQ_UML_CLS_C_9293). ConstThe concept of Const function is not supported by C code generator. FriendThe concept of Friend operation is not supported by the C code generator. The usage of a relation applying the C++ Friend stereotype is not supported. Function PointerFunction pointer not yet supported. Add a validation rule. OperatorThe concept of Operator is not supported by the C code generator. ExceptionThe concept of exception is not supported by the C code generator. GlobalThe concept of exception is not supported by the C code generator. Operation Behavior
A behavior can be attached to an operation to represent its implementation. This can be done using the Method attribute of an operation. If an activity is assigned to an operation, a variable typed with the struct representing the activity is declared in the private section of the class containing the operation.
typedef struct block1{
/**
* Instance of Activity associated to operation op1
*/
Model_Act1_struct Model_Act1_Activity;
}
Example: Operation with activity IMPLEMENTATION MEMBERS SECTIONEach operation declared in a UML class is generated in the source file. ![]() A brief description is generated for any property describing the type and name of the variable. Additional documentation is generated if the documentation section is a field in the model. User code section is inserted in operation to let the user fills a behavior. If any, a default return code is inserted in the user code section.
/**
* @brief Public operation isClosed
* @generated_from _2022x_16600ad_1673944282153_805594_18447
*/
Boolean VehicleDoorsManager_lockDoors(VehicleDoorsManager* self){
/* BEG_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
/* Add your code here */
return 0;
/* END_USER_CODE(_2022x_16600ad_1673944282153_805594_18447) do not remove */
}
Example: Operation implementation ConstructorDefault constructor is automatically generated for class object even if not declared in the class. Constructor parameters and implementation are automatically implemented to enable proper initialization of elements. Default constructor initializes the destructor as the first step.
/**
* Constructor generated automatically to initialize data structure
* @generated_from _2022x_16600ad_1673888904467_347445_17229
*/
void VehicleDoorsManager_ctor(VehicleDoorsManager* self, struct LockManager* lockManager){
/* Init pointer to destructor */
self->dtor = VehicleDoorsManager_dtor;
/* Init pointer to virtual table */
Self->vtable = &vtable;
/* Init aggregation destination */
self->lockManager = lockManager;
/* Default values */
/* Call hierarchical constructors */
Door_ctor(&self->frontRightDoor);
Door_ctor(&self->rearLeftDoor);
Door_ctor(&self->rearRightDoor);
Door_ctor(&self->frontLeftDoor);
}
Example: Default Constructor If an operation uses the stereotype C++ Constructor, the function is generated as a constructor in the source code.
/**
* @brief Public constructor
* @generated_from _2022x_16600ad_1677662449242_503106_17437
*/
void VehicleDoorsManager_user_ctor(VehicleDoorsManager* self){
/* BEG_USER_CODE(_2022x_16600ad_1677662449242_503106_17437) do not remove */
/* Add your code here */
/* END_USER_CODE(_2022x_16600ad_1677662449242_503106_17437) do not remove */
}
Example: Constructor Explicit ConstructorThe concept of Explicit constructor is not supported by C code generator. DestructorA default destructor is automatically generated for a class object even if not declared in the class. This destructor is implemented as a static function. Default destructor called automatically destructor of contained elements when required.
/* Function pointer to destructor function generated automatically */
static void VehicleDoorsManager_dtor(struct VehicleDoorsManager* self){
/* Call hierarchical destructors */
self->frontRightDoor.dtor(&self->frontRightDoor);
self->rearLeftDoor.dtor(&self->rearLeftDoor);
self->rearRightDoor.dtor(&self->rearRightDoor);
self->frontLeftDoor.dtor(&self->frontLeftDoor);
/* Clean pointer to destructor */
self->dtor = NULL;
}
Example: Destructor implementation Default destructor is configured in the default constructor.
/**
* Constructor generated automatically to initialize data structure
* @generated_from _2022x_16600ad_1673888904467_347445_17229
*/
void VehicleDoorsManager_ctor(VehicleDoorsManager* self, struct LockManager* lockManager){
/* Init pointer to destructor */
self->dtor = VehicleDoorsManager_dtor;
}
Example: Constructor initialization Getter/SetterGetter and setter are generated for each function declared accordingly in the model and content is automatically generated to access or modify the associated attribute.
/**
* @brief Setter method for attribute WindowPosition
* @generated_from _2022x_16600ad_1677147742721_382790_17804
*/
void Door_setWindowPosition(Door* self, ControlEnum /*in*/ windowPosition){
self->WindowPosition = windowPosition;
}
/**
* @brief Getter method for attribute WindowPosition
* @generated_from _2022x_16600ad_1677147745041_9971_17808
*/
ControlEnum Door_getWindowPosition(Door* self){
return self->WindowPosition;
}
Example: Getter and setter InlineIf an operation uses the stereotype C++ operation and the attribute Inline is set to true, the function is generated as an inline function.
/**
* @brief Public operation isLocked
* @generated_from _2022x_16600ad_1677575910398_769750_17568
*/
inline bool LockableElement_isLocked(LockableElement* self){
/* BEG_USER_CODE(_2022x_16600ad_1677575910398_769750_17568) do not remove */
/* Add your code here */
return 0;
/* END_USER_CODE(_2022x_16600ad_1677575910398_769750_17568) do not remove */
}
Example: Inline Operation BehaviorIf an opaque behavior is assigned to an operation, this opaque behavior is replicated in the operation body.
void ClassA_OperationWithBeh(ClassA* self){
/* BEG_USER_CODE(_2024x_1ca00d3_1700818869010_751926_3013) do not remove */ FriendClass c;
c.privateOp();
/* END_USER_CODE(_2024x_1ca00d3_1700818869010_751926_3013) do not remove */
}
Example: Operation with behavior If an activity is assigned to an operation, this activity must be invoked in the operation body. The invoke phase consist in a first initialization performed once flowed by the call of the activity code.
/**
* @brief Public operation op1
* @generated_from _2024x_1_1ca00d3_1715702379719_574529_3630
*/
Integer block1_op1(block1* self, Integer /*in*/ param1, Integer /*in*/ param2){
static Boolean first = true;
if(first){
_basic_Model_Act1_init(&self->Model_Act1_Activity);
first = false;
}
self->Model_Act1_Activity.param1=param1;
self->Model_Act1_Activity.param2=param2;
self->Model_Act1_Activity.WALL_CLOCK = tal_GetTime();
(void)_basic_Model_Act1(&self->Model_Act1_Activity);
return self->Model_Act1_Activity.param3;
}
Example: Operation with activity VIRTUAL TABLE MEMBERS SECTIONA function pointer is declared for each public operation in the virtual table to access the function with an object-oriented style. The name of the function pointer is the name of the operation. /** * @brief Public operation LockableElement_lockDoors * @generated_from _2022x_16600ad_1673944282153_805594_18447 */ Boolean (*lockDoors)(struct LockableElement* self); Example: Pointer to operation in a virtual table VIRTUAL TABLE MEMBERS INITIALIZATION SECTIONthe function pointer for each operation is initialized in the virtual table with the function declared in section FUNCTIONS DECLARATION SECTION and PROTECTED AND PRIVATE FUNCTIONS SECTION. All operations must be declared exactly in the same order than fct pointers are defined. Operations are defined before variables.
/** vtable variable declaration */
const LockableElement_vtable LockableElement_vt = {
LockableElement_user_ctor,
LockableElement_virtualOperation,
LockableElement_isLocked,
LockableElement_isUnlocked,
LockableElement_lock,
LockableElement_unlock,
};
Example: Operation initialized in the virtual table Operation ParameterFUNCTIONS DECLARATION SECTION and IMPLEMENTATION MEMBERS SECTIONType of parameter of operation with direction set as return is used as the return type of the operation. Parameter of operation with direction set as in or out or inout is used as parameter of the operation. Type of parameter of operation with direction set as in or out or inout is used in parameter declaration of the operation. Direction in or out or inout of parameter is used for documentation purpose. /** * @generated_from _2022x_16600ad_1677147742721_382790_17804 */ void Door_setWindowPosition(Door* self, ControlEnum /*in*/ windowPosition); Example: Parameters Pointer DeclarationIf a type modifier * is set for a parameter, it is used to declare a pointer to a variable. /** * @generated_from _2022x_16600ad_1677147742721_382790_17804 */ void Door_setWindowPosition(Door* self, ControlEnum* /*out*/ windowPosition); Example: Pointer List DeclarationThe concept of List is not supported by the C code generator. Array DeclarationIf the parameter applies the C++ Attributes stereotypes and array value is configured, parameter is generated as an array<Parameter Type, length>. ![]() /** @generated from: _2022x_2_1ca00d3_1685001263779_527188_17508 */ void Configuration_setConfiguration(Configuration* self, Integer /*in*/ configuration[2]); Example: Parameter as array Variable Length Parameter ListVariable length parameter lists are not yet supported. Add a validation rule. Dependency RelationIn case of a dependency relation between 2 objects (UML class or UML Interfaces) target elements of the relation are automatically generated if the source of the relation is part of the generation. Flow PortHEADER VARIABLE MEMBERS SECTIONA variable is expected to be created in the class to store the values exchanged by the flow ports of the class. For each flow port, a variable typed with the type referenced by the flow port is generated. For each flow port, a variable named with the name of the Port and a suffix _data is generated. /** * Public data for Flow Port flowPort * @generated from: _19_0_3_16600ad_1654593633874_525666_43081 */ Integer flowPort_data; Example: Flow port variable Proxy Port and Interface Block and Flow PropertyHEADER VARIABLE MEMBERS SECTIONA variable is expected to be created in the class to store the values exchanged by the flow properties transmitted through proxy ports of the class. For each flow property contained in an interface block, which is referenced by a proxy port, a variable typed with the type referenced by the flow property is generated. For each flow property contained in an interface block, which is referenced by a proxy port, a variable named with the name of the proxy port, an _ and the flow property name is generated. /** * Public data for Flow Property myFlowProperty of Interface Block myItf in Proxy Port myPort * @generated from: _19_0_3_16600ad_1654593633874_525666_43081 * @generated from: _19_0_3_16600ad_1654593633874_525666_43082 * @generated from: _19_0_3_16600ad_1654593633874_525666_43083 */ Integer myPort_myItf; Example: Flow property variable Port, Interface and PropertyHEADER VARIABLE MEMBERS SECTIONA variable is expected to be created in the class to store the values exchanged by the properties transmitted through ports of the class. For each property contained in an interface, which is referenced by a port, a variable typed with the type referenced by the property is generated. For each property contained in an interface, which is referenced by a port, a variable named with the name of the port, an _ and the property name is generated. /** * Public data for Property myFlowProperty of Interface myItf in Port myPort * @generated from: _19_0_3_16600ad_1654593633874_525666_43081 * @generated from: _19_0_3_16600ad_1654593633874_525666_43082 * @generated from: _19_0_3_16600ad_1654593633874_525666_43083 */ Integer myPort_myItf; Example: Flow property variable InterfaceHEADER VARIABLE MEMBERS SECTION and HEADER CONST MEMBERS SECTIONAn interface is translated into several structures containing fields and operations corresponding to the properties and operations of the class. Refer to chapter <ClassName>.h for more details. The list of functions declared outside the structure like generated for a class are not generated in case of a structure. A file named <interface name>.h must be created, except for C standard Library headers. IMPLEMENTATION MEMBERS SECTIONAs a rationale, only a header file is generated. Classifier BehaviorHEADER VARIABLE MEMBERS SECTIONA variable typed with the structure of the behavior is generated for the classifier behavior with public visibility. See [4] for more information on the structure naming. All structures are named with the same pattern. A variable having the name of the behavior is generated for the classifier behavior with public visibility. /** * Data for Behavior Statemachine * @generated from: _19_0_3_16600ad_1654593633874_525666_43081 */ Statemachine_struct Statemachine; Example: Classifier behavior variable Data Type and Value Type and Enumeration
Data Types generation in class is not yet supported. A type can be a redefinition of an existing type using a generalization relation. ![]() Data Types and Value Types are used to type the data contained in classes. DATA TYPES DECLARATION
Each Data Type or Value Type that are referenced by a property, parameter, operation argument, are expected to be defined in internal_types.h. Primitive TypeData types defined in C++ ANSI profile are supported. No typedef must be generated. ![]() Data types defined in UML Standard Profile/MagicDraw profile/datatypes are supported. Typedef is generated or not according to the following requirements. ![]() Datatypes defined in UML Standard Profile/MagicDraw profile/datatypes Color, StructuredExpression, date and XML are not supported. Data types defined in UML Standard Profile/UML 2 Metamodel/Primitive Types are supported. Typedef is generated according to the following requirements. ![]() Datatype defined in UML Standard Profile/UML 2 Metamodel/Primitive Types UnlimitedNatural is not supported. ![]() Data types defined in SysML/Libraries/PrimitiveValueTypes are supported. Typedef is generated according to the following requirements. ![]() Datatypes defined in SysML/Libraries/PrimitiveValueTypes” Complex” and Number are not supported. A Data Type or a Value Type having one of the following names are not defined:
If an Integer type of the following profiles is referenced directly or indirectly in the design, an Integer type is generated:
Integer is defined as an int. #ifndef Integer_DEFINITION #define Integer_DEFINITION typedef int Integer; #endif Example: Integer type declaration If a Boolean type of the following profiles is referenced directly or indirectly in the design, a Boolean type is generated:
Boolean is defined as a bool. #ifndef Boolean_DEFINITION #define Boolean_DEFINITION typedef bool Boolean; #endif Example: Boolean type declaration If a Real type of the following profiles is referenced directly or indirectly in the design, a Real type is generated:
Real is defined as a double. #ifndef Real_DEFINITION #define Real_DEFINITION typedef double Real; #endif Example: Real type declaration If a String type of the following profiles is referenced directly or indirectly in the design, a String type is generated:
String is defined as a char*. #ifndef String_DEFINITION #define String_DEFINITION typedef char* String; #endif Example: String type declaration If a primitive type uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the attribute alignment is set to a valid value, then the generated code must include the keyword __attribute__((aligned({alignment}))).
typedef int __attribute__((aligned({alignment}))) alignedInteger;
Example: Primitive type declaration using aligned A valid value for alignment an integer that is a power of two. Array Type![]() An array is generated when a property, a parameter, or a type references another type with a multiplicity greater than 1. An array is defined with a naming convention as the following: Array_<size>_<referencedType>. /********************************************************************** * Data Type Array_3_Integer definition **********************************************************************/ #ifndef Array_3_Integer_DEFINITION #define Array_3_Integer_DEFINITION typedef Integer Array_3_Integer[3]; #endif /* Array_3_Integer */ Example: Array definition in model If an array type uses the stereotype C++Aligned, and thecompiler” parameter is set to gcc, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))).
typedef int __attribute__((aligned({alignment}))) Array_3_Integer[3];
Example: Array type declaration using aligned A valid value for alignment an integer that is a power of two. Structure Type![]() A struct is defined for a value type or a data type containing one or multiple properties.
/**********************************************************************
* Data Type Struct definition
**********************************************************************/
#ifndef Struct_DEFINITION
#define Struct_DEFINITION
typedef struct {
unsigned int data1;
double data2;
bool data3;
} Struct;
#endif /* Struct */
Example: structure definition If the structure type uses the stereotype C+Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)).
typedef struct __attribute__((packed)) {
int attribute1;
int attribute2;
} StructType;
Example: Structure declaration with packed If the property of the structure type uses the stereotype C++Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)), except for bitfield, pointer and reference properties.
typedef struct {
int attribute1;
struct OtherStrucType __attribute__((packed)) attribute2;
} StructType;
Example: Property structure declaration with packed If the structure type uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))).
typedef struct __attribute__((aligned({alignment}))) {
int attribute1;
int attribute2;
} StructType;
Example: Structure declaration using aligned A valid value for alignment is an integer that is a power of two. If the property of the structure type uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the selected C version is not greater than or equal to C23, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))) except for bitfield and reference properties.
typedef struct {
int attribute1;
struct OtherStrucType __attribute__((aligned({alignment}))) attribute2;
} StructType;
Example: Property structure declaration using aligned A valid value for alignment is an integer that is a power of two. If the property of the structure type uses the stereotype C++Aligned, and the selected C version is greater than or equal to C23, and the attribute alignment is set to a valid value, the generated code must include the keyword alignas({alignment}) except for bitfield and reference properties.
typedef struct {
int attribute1;
alignas({alignment}) struct OtherStrucType attribute2;
alignas(16) int *attribute3;
} StructType;
Example: Property structure declaration using alignas A valid value for alignment is an integer that is a power of two. Enumeration TypeAn enum is identified as an Enumeration in the design. ![]() An enum is defined for an enumeration.
/**********************************************************************
* Data Type ControlEnum definition
* @generated_from _2022x_16600ad_1673975868491_889391_20271
**********************************************************************/
#ifndef ControlEnum_DEFINITION
#define ControlEnum_DEFINITION
typedef enum {
Idle,
Open,
Close
} ControlEnum;
#endif /* ControlEnum */
If the enumeration uses the stereotype C++Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)).
enum __attribute__((packed)) EnumPacked{
literal1,
literal2
};
Example: Enumeration declaration with packed If an enumeration literal has the attribute value of C++ANSI profile defined, then the value of that attribute is used in the generated code. The value attribute must be a signed integer.
enum EnumPacked{
literal1 = 1,
literal2
};
Example: Enumeration declaration with attribute value defined If an enumeration literal has a specification of the kind Literal Integer defined, the value of that specification is used in the generated code. If an enumeration literal has both a specification and the attribute value of C++ANSI Profile defined, the value is used in the generated code instead of the specification. If neither the specification nor the value attribute of the C++ ANSI Profile is defined for an enumeration literal, the name of the enumeration literal is used in the generated code. If the enumeration uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))).
enum __attribute__((aligned({alignment}))) MyEnumeration {
literal1,
literal2
};
Example: Enumeration declaration using aligned A valid value for alignment is an integer that is a power of two. Union TypeIf a union uses the stereotype C++Packed, and the attribute packed is set to true, and the compiler parameter is set to gcc, the generated code must have the keyword __attribute__((packed)).
typedef union __attribute__((packed)) MyUnion {
int i;
double d;
} MyUnionType;
Example: Union declaration using alignment If a union uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))). typedef union __attribute__((aligned({alignment}))) MyUnion { int i; double d; }; Example: Union declaration using aligned A valid value for alignment is an integer that is a power of two. SignalDATA TYPES DECLARATIONEach signal, which is received or produced by any behavior, is expected to be defined in internal_types.h. If a component contains one or multiple signals, a trigger_type is generated. /********************************************************************** * Data Type trigger_type definition **********************************************************************/ #ifndef trigger_type_DEFINITION #define trigger_type_DEFINITION typedef bool trigger_type; #endif /* trigger_type */ Example: Trigger_type declaration If a signal references one or multiple properties, a dedicated structure is generated for the data transmitted with the signal.
/**********************************************************************
* Data Type Signal definition
**********************************************************************/
#ifndef Signal_DEFINITION
#define Signal_DEFINITION
typedef struct {
Integer s1;
Integer s2;
} Signal;
#endif /* Signal */
Example: Signal content declaration A signal type is declared by a structure named SignalEvent_<signal_name>l_type. This structure contains at least one trigger field with type trigger_type to store the event activation. If a signal references one or multiple properties, an addition field named <signal_name> is added to the structure.
/**********************************************************************
* Data Type SignalEvent_Signal_type definition
**********************************************************************/
#ifndef SignalEvent_Signal_type_DEFINITION
#define SignalEvent_Signal_type_DEFINITION
typedef struct {
trigger_type trigger;
Signal data;
} SignalEvent_Signal_type;
#endif /* SignalEvent_Signal_type */
If the signal uses the stereotype C++Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)).
typedef struct __attribute__((packed)) {
trigger_type trigger;
Signal data;
} SignalEvent_Signal_type;
Example: Signal declaration with packed If the property of the signal uses the stereotype C++Packed and the attribute packed is set to true and the compiler parameter is set on gcc, the generated code must have the keyword __attribute__((packed)), except for bitfield, pointer and reference properties.
typedef struct {
trigger_type trigger;
Signal __attribute__((packed)) data;
} SignalEvent_Signal_type;
Example: Property signal declaration with packed If the signal uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))).
typedef struct __attribute__((aligned({alignment}))) {
trigger_type trigger;
Signal data;
} SignalEvent_Signal_type;
Example: Signal declaration using alignment A valid value for alignment is an integer that is a power of two. If the property of the signal uses the stereotype C++Aligned, and the compiler parameter is set to gcc, and the selected C version is not greater than or equal to C23, and the attribute alignment is set to a valid value, the generated code must include the keyword __attribute__((aligned({alignment}))) except for bitfield, pointer, and reference properties.
typedef struct {
trigger_type trigger;
Signal __attribute__((aligned({alignment}))) data;
} SignalEvent_Signal_type;
Example: Property signal declaration using alignment A valid value for alignment is an integer that is a power of two. If the property of the signal uses the stereotype C++Aligned, and the selected C version is greater than or equal to C23, and the attribute alignment is set to a valid value, the generated code must include the keyword alignas({alignment}) except for bitfield and reference properties.
typedef struct {
trigger_type trigger;
alignas({alignment}) Signal data;
} SignalEvent_Signal_type;
Example: Property signal declaration using alignas A valid value for alignment is an integer that is a power of two. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||