Proposal to add rule for nested CPP Directives in RTEMS coding conventions
Vaibhav Gupta
vaibhav.varodek at gmail.com
Fri Apr 3 19:51:52 UTC 2020
CPP directives like:
1) #if
2) #ifdef
3) #ifndef
4) #elif
5) #else
6) #endif
do form code blocks. Since, they don't make use of brackets,
as a part of C language rule, their nested and repeated use
can make the code very hard to read. Can even result it
spaghetti code.
This can be understood by this patch:
https://lists.rtems.org/pipermail/devel/2020-April/058964.html
The proposed idea is:
1) Nested CPP directives should follow same indentation rules
as of nested conditional statements like 'if' and loops.
2) To mark which closing CPP directive (#endif) pairs with which
opening CPP directive (#if or #ifdef or #ifndef), make use of comments.
ex:
#ifdef <some-macro> /* To test/verify/enable xyz */
.....
....
#endif /* To test/verify/enable xyz */
--Vaibhav Gupta
More information about the devel
mailing list