C Code Architecture Specification

This section describes the UML and SysML to C architecture.

This page discusses:

General Concepts

C code generators produce code from an input model. The code is generated into files.

The generated files are standardized to contain the same type of information to ease the readability.

Code Generator Specification

This section is divided in 2 parts:

  • The generated files specifications
  • The behavior specifications

Files Specifications

Common to All Files

Operations generates a header for c++ files. The C and C++ code deployment feature defines how to do configure this header

For the header file, the following header a macro definition header is created to avoid multiple inclusion of the same file.

#ifndef BUTTON_BUTTON_H
#define BUTTON_BUTTON_H

Example: Inclusion macro protection

The inclusion of a header is done after the header of the multiple inclusion macro.

Rationale: MISRA requires that nothing except the macro definition is positioned on top of includes.

**To Be Confirmed, Rule number**

For the header file, before the final line printed, a macro definition closing the inclusion macro protection macro is inserted.

#endif /*BUTTON_BUTTON_H*/

Example: Inclusion macro protection closure

The last line of the file is a standard line indicating that the file generation is completed.

/* end of file */

Example: End of file

The first line of the file is a timestamp.

Semantic Code Specifications

This section describes the behavior of the code generator depending on the input element.

generated_from tag

Tag @generated_from is inserted every time a code or a code section is generated for a specific element.

User Code Section

User code section identifies a user-specific code area that can be modified by the user and which can be protected when a file is regenerated.

User code section starts with a comment BEG_USER_CODE(<ID>).

User code section starts with a comment END_USER_CODE(<ID>).

User code section uniqueness is identified in the file via its <ID>.

Note: Comments BEG_USER_CODE(<ID> ) and END_USER_CODE(<ID>) must not be deleted.

Note: <ID> must not be modified.