Integrations (PTC products, 3rd party products and code) > Code integration (Ada, ARINC 653, C, C#, C++, IDL, Java, SQL and VB) > C Code > Generating C Code > Overview of generating C code (C code) > Overview of modeling C code (C code) > Overview of modeling C code (C code) > Data type mapping for C (C code)
  
Data type mapping for C (C code)
For each Data Type that is not nested, ACS generates a header file (.h) and an implementation file (.c). Each Data Type maps to a struct in the header file created for the Data Type, unless the Data Type is stereotyped by the «C Module» stereotype.
ACS ignores Data Types that are stereotyped by the «requirement» stereotype, which is available in the SysML Requirements profile.
Data Types that Implement Interfaces
For Data Types that implement interfaces:
The first member of the generated struct is named 'base' and is typed by the implementing interface.
ACS generates a 'constructor' function, assigns appropriate functions to the function pointer members of the 'base' member, and assigns values to behavior ports.
The Data Type provides proxies for functions being forwarded to behavior ports that cast the instance parameter to the correct concrete type before making a call.
For Data Type containing composite interface-typed non-behavior ports, ACS generates constructor functions that assign functions to the port's function pointer members.
The struct declaration and implementation is derived from the items it owns, properties of the Data Type, the application of the «C Module» stereotype, and the tagged values set for Tag Definitions applied by the «C Class» stereotype.
Child items:
If the Data Type owns Attributes, the Attributes are generated within the struct declaration. For Attribute mapping information, see Attribute mapping for C (C code)
If a typed Part (Attribute) has an Association that has not been rolled up to the Part's type, ACS generates a nested struct that is derived from the Part's type. The nested struct defines the Role that is modeled against the Part.
If a Data Type owns Parts (Attributes or Roles) that are connected through an Association, initialization code is generated in the constructor for the Data Type.
Reverser Notes: When reverse engineering a struct's attributes, the Reverser will reverse engineer an attribute as a Role if all of the following statements are true:
The C attribute's data type can be identified as a struct in the code being reverse engineered.
The C struct that is used as a data type is being reverse engineered.
The Reverser cannot match the C attribute to an Attribute in the Model.
For Attributes that are set up as ports, see the preceding Data Types that Implement Interfaces section.
If the Data Type owns Dependencies, ACS typically generates #includes in the code. For Dependency mapping information, see Dependency mapping for C (C code)
If the Data Type owns Generalizations that define inheritance, the attributes are rolled down. Rolled down attributes are indicated through comments. For Generalization mapping information, see Generalization mapping for C (C code)
If the Data Type owns Operations, the Operations are generated in the file created for the owning Data Type, but outside of the struct definition. For Operation mapping information, see
If the Data Type owns Roles, the Roles are typically generated as attributes within the struct declaration. For Role mapping information, see
If a typed Part (Role) has an Association that has not been rolled up to the Part's type, ACS generates a nested struct that is derived from the Part's type. The nested struct defines the Role that is modeled against the Part.
If a Data Type owns Parts (Attributes or Roles) that are connected through an Association, initialization code is generated in the constructor for the Data Type.
For Roles that are set up as ports, see the preceding Data Types that Implement Interfaces section.
Properties:
The Abstract property is ignored.
If the Description property has a value, ACS generates the description as a comment on the line before the struct declaration.
The Formal Template Parameters property is ignored.
The Name property is generated as the name of the header and implementation files, and the name of the struct in the code.
* 
ACS may modify the struct name that is added to the code to make it valid for C. You can specify the exact struct name to add to the code through the CODE_GENERATION_NAME property of a Data Type.
The Persistent property is ignored.
The Template property is ignored.
The Template Specialization Parameters property is ignored.
The Template Specialization property is ignored.
If the Visibility property is set to Public or Protected, the struct is declared in the header file. If the Visibility property is set to Private, the struct is declared in the implementation file. For nested Data Types, this property is ignored.
Tag Definitions:
If the «C Module» stereotype is applied to a Data Type, ACS generates a header and implementation file for the Data Type, but it does not generate a struct for the Data Type. For nested Data Types, this stereotype is ignored.
The following tag definition is applied to a Data Type by the «C Class» stereotype:
If the tagged value of the C Anonymous Item tag definition is set to TRUE, it means that the struct is used as an anonymous type and is generated inline.
If the tagged value of the C Forward Declarations tag definition references any Classes, Data Types, Interfaces and Type Definitions, ACS generates forward declarations to the structs, unions and enums that are generated from those items.
If the tagged value of the C Forward Declaration Text tag definition has been set, the value is generated as forward declarations.
If the tagged value of the C Header File tag definition has been set, the value is used to generate #include statements. This value is set by ACS and is used when opening an associated header file from Modeler.
If the tagged value of the C Header File Comment tag definition has been set, the value is generated as a header file comment.
If the tagged value of the C Header Include tag definition has been set, the value is generated at the beginning of the header file so that you can generate your own #includes to files that are not modeled in the Mode
* 
You can use Dependencies to generate #includes to other Classes, Data Types and Interfaces that are modeled in the Model.
If the tagged value of the C Implementation File Comment tag definition has been set, the value is generated as an implementation file comment.
If the tagged value of the C Implementation Include tag definition has been set, the value is generated at the beginning of the implementation file so that you can generate your own #includes to files that are not modeled in the Model. Note that you can use Dependencies to generate #includes to other Classes, Data Types, Interfaces and Signals that are modeled in the Model.
If the tagged value of the C Non Member tag definition is set to TRUE (applies only to nested Data Types), ACS generates the struct in the code file created for the root item, but not as part of the struct created for the root item.
If the tagged value of the C Source File tag definition has been set, the value is used when opening an associated implementation file from Modeler. This value is set by ACS
The C Generate State Machine tag definition does not apply to Data Types.
The following tag definition is applied to a Data Type by the «C Library» stereotype:
If a value has been set for the tagged value of the C LIB_INCLUDE tag definition, the value is generated as the #include for any structs that use the library, rather than ACS generating a #include based on the library's location in the model.