## CTYPEDEFINE Define C Type

Section: FreeMat External Interface

### Usage

The `ctypedefine` function allows you to define C types for use with FreeMat. Three variants of C types can be used. You can use structures, enumerations, and aliases (typedefs). All three are defined through a single function `ctypedefine`. The general syntax for its use is

      ctypedefine(typeclass,typename,...)

where `typeclass` is the variant of the type (legal values are `'struct'`, `'alias'`, `'enum'`). The second argument is the name of the C type. The remaining arguments depend on what the class of the typedef is. To define a C structure, use the `'struct'` type class. The usage in this case is:

      ctypedefine('struct',typename,field1,type1,field2,type2,...)

The argument `typename` must be a valid identifier string. Each of of the `field` arguments is also a valid identifier string that describe in order, the elements of the C structure. The `type` arguments are `typespecs`. They can be of three types:

- Built in types, e.g. `'uint8'` or `'double'` to name a couple of examples.
- C types that have previously been defined with a call to `ctypedefine`, e.g. `'mytype'` where `'mytype'` has already been defined through a call to `ctypedefine`.
- Arrays of either built in types or previously defined C types with the length of the array coded as an integer in square brackets, for example: `'uint8[10]'` or `'double[1000]'`.

To define a C enumeration, use the `'enum'` type class. The usage in this case is: ctypedefine('enum',typename,name1,value1,name2,value2,...) @] The argument `typename` must be a valid identifier string. Each of the `name` arguments must also be valid identifier strings that describe the possible values that the enumeration can take an, and their corresponding integer values. Note that the names should be unique. The behavior of the various `cenum` functions is undefined if the names are not unique. To define a C alias (or typedef), use the following form of `ctypedefine`:

      ctypedefine('alias',typename,aliased_typename)

where `aliased_typename` is the type that is being aliased to.