Book a Demo

Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Prev Next

Object Oriented Programming In C

In Enterprise Architect, you apply a number of conventions for Object-Oriented programming in C.

To configure the system to support Object-Oriented programming using C, you must set the 'Object Oriented Support' option to True on the 'C Specifications' page of the 'Preferences' dialog.



Applies To

See also



Corresponds To: An enumerated type.



Corresponds To: A 'struct' type.


A keyword struct in variable definition.



Corresponds To: A 'typedef' statement, where the parent is the original type name.



Corresponds To: A union type.


A keyword union in variable definition.

Tagged Values


Applies To

See also


Class with stereotype of 'enumeration', 'struct' or 'union'

Corresponds To: The name of this Class being defined only by the typedef statement.



Corresponds To: The location the method body is generated to; expected values are 'header', 'classDec' or 'classBody'.



Corresponds To: '#define' statement.


Class with stereotype of 'enumeration', 'struct' or 'union'

Corresponds To: This Class being defined in a 'typedef' statement.

Object-Oriented C Code Generation for UML Model

The basic idea of implementing a UML Class in C code is to group the data variable (UML attributes) into a structure type; this structure is defined in a .h file so that it can be shared by other Classes and by the client that referred to it.

An operation in a UML Class is implemented in C code as a function; the name of the function must be a fully qualified name that consists of the operation name, as well as the Class name to indicate that the operation is for that Class.

A delimiter (specified in the 'Namespace Delimiter' option on the 'C Specifications' page) is used to join the Class name and function (operation) name.

The function in C code must also have a reference parameter to the Class object - you can modify the 'Reference as Operation Parameter', 'Reference Parameter Style' and 'Reference Parameter Name' options on the 'C Specifications' page to support this reference parameter.

Limitations of Object-Oriented Programming in C

  • No scope mapping for an attribute: an attribute in a UML Class is mapped to a structure variable in C code, and its scope (private, protected or public) is ignored
  • Currently an inner Class is ignored: if a UML Class is the inner Class of another UML Class, it is ignored when generating C code
  • Initial value is ignored: the initial value of an attribute in a UML Class is ignored in generated C code

Learn more