Next: , Previous: , Up: Introduction   [Contents][Index]


1.12 Conventions for Datatypes

Names of all datatypes defined in the QSMM package are in lowercase letters. The suffixes of those names depend on C language keywords used for datatype definitions:

typedef

The ‘_t’ suffix. Names of datatypes for function pointers have the ‘_func_t’ suffix.

enum

The ‘_e’ suffix.

struct

The ‘_s’ suffix.

union

The ‘_u’ suffix.

Names of all datatypes defined in the QSMM API have the ‘qsmm_’ prefix.

The QSMM framework suggests the following conventions for the use of basic types and the types size_t, qsmm_sig_t, and qsmm_ssig_t in specific situations. These conventions are used in the QSMM API, the package source code itself2, and are recommended for applications based on the framework.

The primary conventions are that if a datatype is intended for signal identifiers or the numbers of signals, and such values

The secondary convention is that for sizes of memory arrays and for non-negative indices of their elements allowed to be greater than 32767, you should use the type size_t.

For other situations, including situations when you choose not to use the type qsmm_sig_t or qsmm_ssig_t according to the first two items of primary conventions stated above, the rules are:

  1. For boolean flags, use the type char or int or use specific bits in values of other numeric types.
  2. For integer quantities that never lie outside the range 0 to 127, use the type char or int.
  3. For integer quantities that may be negative but never lie outside the range -128 to 127, use the type signed char or int.
  4. For non-negative integer quantities that may exceed 127 but never exceed 255, use the type unsigned char or int.
  5. For integer quantities that may be less than -128 but never lie outside the range -32768 to 32767, use the type int.
  6. For integer quantities that may exceed 255 but never lie outside the range -32768 to 32767, use the type int.
  7. For non-negative integer quantities that may exceed 32767 but never exceed 65535, use the type unsigned int.
  8. For non-negative integer quantities that may exceed 65535 but do not have the restriction that they must be at least 64-bit, use the type long or unsigned long.
  9. For integer quantities that may be less than -32768 and may be greater than 32767 but do not have the restriction that they must be at least 64-bit, use the type long.
  10. For integer quantities that must be at least 64-bit, use the type long long or unsigned long long.

For example, in QSMM:

The set of datatypes defined in the QSMM API with the ‘_t’ suffix in their names is comprised of datatypes qsmm_sig_t and qsmm_ssig_t, datatypes for function pointers with the ‘_func_t’ suffix in their names, and datatypes for object handles. See Object Handles, for more information about datatypes for object handles.

Datatypes defined in the QSMM package with the ‘_e’ suffix in their names are enumerations. Elements of enumerations are listed in uppercase.

Datatypes with suffixes ‘_s’ and ‘_u’ are structures and unions respectively. The order of definition of their elements depends on datatypes of those elements and is the following:

  1. Elements of basic types (except for the void type) are defined in the following type order: char, signed char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double.
  2. Elements of types defined in the QSMM package with the ‘_t’ suffix in their names.
  3. Elements of other types, except for types which names should be prepended with specifier ‘enum’, ‘struct’, or ‘union’.
  4. Elements of types which names should be prepended with specifier ‘enum’. Enumerations defined in the QSMM package go first.
  5. Elements of types which names should be prepended with specifier ‘struct’. Structures defined in the QSMM package go first.
  6. Elements of types which names should be prepended with specifier ‘union’. Unions defined in the QSMM package go first.
  7. Elements of the void type.

For every type name within each type category listed above, the type order is the following:

  1. Non-pointer and non-array types (not applicable to the void type).
  2. Arrays (but not pointers to arrays), including arrays of pointers.
  3. Pointer types (except for arrays of pointers) which full names begin with the const qualifier in the order of increase of the number of asterisks.
  4. Pointer types (except for arrays of pointers) which full names do not begin with the const qualifier in the order of increase of the number of asterisks.

Footnotes

(2)

As of QSMM version 1.17, not all package source code is yet reworked to meet these conventions.


Next: , Previous: , Up: Introduction   [Contents][Index]