Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Capital snake case on all constants, #defines, and enumerations
  • Typedef enums
  • Defines that are only used in a single c file, and aren't meant to be modified by the developer should be placed in the .c file, not the .h file

Example

#define HELLO_WORLD 4

...

For code portability and easier unit testing, please use the types defined in <stdint.h> and <stdbool.h>. The table below summarizes the different possible types and their conversion to the standard types. As you can see, it also saves on a lot of typing.

C Standard TypeLength in Bytes (XC16)Portable Type
char1int8_t
unsigned char1uint8_t
int2int16_t
unsigned int2uint16_t
long int4int32_t
long unsigned int4uint32_t
long long int8int64_t
unsigned long long int8uint64_t
float4--
double4--
long double8--

1bool

Note that with the inclusion of <stdbool.h>, you get the true and false types available to use.