Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Changes
Page history
Update coding_standards
authored
Feb 21, 2019
by
Luke Simonson
Hide whitespace changes
Inline
Side-by-side
c/coding_standards.md
View page @
3cad5ced
...
...
@@ -547,6 +547,11 @@ Better alternatives to `#defines` are discussed below
*
`#define MIN_OF (a, b) (((a) < (b)) ? (a) : (b)) // THIS IS GOOD`
*
`if`
macro statements should always follow the pattern:
`#if (...)`
*
Example with multiple conditions:
`#if ((...) && (...))`
*
Avoid using
`#ifdef MACRO`
when
`#if MACRO`
can be used
*
Example:
*
`#define MACRO 0`
*
`#if MACRO // this is clear`
*
`#ifdef MACRO // this is not clear because it is not dependent on the actual value of MACRO`
*
Macro invocations
**do not**
need to be surrounded in parentheses.
*
Example:
*
`#if FEATURE_UDS // This is perfectly fine`
...
...
...
...