Skip to main content
Untitled Document

Named Constants

Named Constants

Named Constants

The complete format for defining a named constant is:

          CONST [type[*cexpr]] identifier [ '[' [ cexpr ] ']' ]
             '=' { cexpr | '{' cexpr1[',' cexpr2...]'}' | '"'...'"'}
             [ ',' identifier2...]


CONST denotes the beginning of a constant definition clause.


Defines the type of the constant. If none is given, the constant becomes universal type which is 32 bit signed.

'[' [ cexpr ] ']'

Defines a constant array (see array variable types). A constant array will not take any space unless it is indexed at least once with a non-constant subscript. On the PIC, constant arrays consume *code* space, not *data* space.
If cexpr is ommitted, the size of the array will be determined by the number of initializers used.

'=' cexpr

For non-array constants this assigns the value to the constant.

'=' '{' cexpr[',' cexpr2...] '}'

For arrays of constants this assigns the value to each element. There must be the same number of cexprs as there are elements defined.

'=' '"' ... '"'

For an array of constants, this assigns each ASCII value between '"' and '"' to one element of the constant array. Unlike C, there is no terminating NUL.