14-09-2016, 02:23 PM
Does the following example violate Rule 11.9?
Code:
#define FOO NULL
int32_t *p1 = FOO;
<t></t>
Welcome to the new MISRA discussion forum, if you were previously a member of our forums you may need to reset your password.
Does Rule 11.9 allow indirect expansion from NULL?
|
14-09-2016, 02:23 PM
Does the following example violate Rule 11.9?
Code: #define FOO NULL
<t></t>
15-09-2016, 07:39 AM
rgamble Wrote:Does the following example violate Rule 11.9?There is a note in rule 11.9 that says: Quote:a null pointer constant of the form (void*)0 is permitted, whether or not it was expanded from NULLThere is also the following sample code: Code: #define MY_NULL_2 (void*)0
<t></t>
15-09-2016, 03:10 PM
I don't think it is a violation. However, the intention of the rule is to increase clarity and your macro reduces clarity.
The note is not relevant to your example. The compliant example given by @dg1980 is not necessarily identical, as the actual expansion of the NULL macro is implementation-defined.
<t></t>
23-09-2016, 07:49 AM
Your example does not violate rule 11.9 as the value is derived from NULL.
Rule 11.9 permits "NULL", (void *)0 and any macros that expand to these values.
Posted by and on behalf of the MISRA C Working Group
|
« Next Oldest | Next Newest »
|