File Names
- File names should follow capital camel case
Variables
- Variables should be named in lower snake case. ie. `this_is_a_variable`.
- Absolutely no exposing of global variables. All components should implement accessor methods, if applicable.
- Variables in c files should be declared as static if they are outside the scope of any function. This ensures that the variable scope is contained within that file, and tells the developer that the variable isnt used anywher else.
...
Info | ||
---|---|---|
| ||
Note that in most cases, you're NOT going to want to declare a variable as static if inside a function. You only want to declare static inside c files with global variables. |
Functions
- Camel case on all functions. Eg. helloWorld()
...
C Standard Type | Length in Bytes (XC16) | Portable Type |
---|---|---|
char | 1 | int8_t |
unsigned char | 1 | uint8_t |
int | 2 | int16_t |
unsigned int | 2 | uint16_t |
long int | 4 | int32_t |
long unsigned int | 4 | uint32_t |
long long int | 8 | int64_t |
unsigned long long int | 8 | uint64_t |
float | 4 | -- |
double | 8 | -- |
long double | 8 | -- |
-- | 1 | bool |
Info | ||
---|---|---|
| ||
Note that with the inclusion of <stdbool.h>, you get the true and false types available to use |
Info | ||
---|---|---|
| ||
On most systems, a long double guarantees 8 bytes. Even though with XC16 they are the same, it is highly recommended to use long doubles over doubles. |