Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 19.4
#1
Is the usage of ternary operator (? :) inside a C macro violation of rule 19.4. For e.g. the following function-like macro

#define abs(x) (((x) >= 0) ? (x) : -(x))

According to Rule 19.4 - C macros shall only expand to a braced initialiser, a constant, a parenthesized expression, a type qualifier, a storage class specifier or a do-while construct.

Does the above function-like macro conform to rule 19.4?
<t>--------------------------------------------------------<br/>
Aravind Pillarisetti<br/>
The MathWorks<br/>
--------------------------------------------------------</t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)