08-11-2011, 04:05 PM
I have a violation of MISRA 2004 Advisory Rule 19.7, Function-like macro defined: 'CONV'
#define F_MIN (-0.5)
#define F_MAX (0.5)
#define CONV(x) ((int32_t) ((x) < F_MAX ? ((x) >= F_MIN ? (x)*0x80000000U : 0xFFFF8000U) : 0x7fff0000U))
int32_t myVariable = CONV(0.25); /* the preprocessor replace macro with the value 0x20000000 */
How I declare the macro CONV(), which is not a function but really a preprocessor task, to be compliant to MISRA ?
BR,
Pat
#define F_MIN (-0.5)
#define F_MAX (0.5)
#define CONV(x) ((int32_t) ((x) < F_MAX ? ((x) >= F_MIN ? (x)*0x80000000U : 0xFFFF8000U) : 0x7fff0000U))
int32_t myVariable = CONV(0.25); /* the preprocessor replace macro with the value 0x20000000 */
How I declare the macro CONV(), which is not a function but really a preprocessor task, to be compliant to MISRA ?
BR,
Pat
<t></t>