MISRAC++2008-18-2-1
In this section:
Synopsis
(Required) The macro offsetof shall not be used.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
Uses of the built-in function offsetof were found. This check is identical to MISRAC2004-20.6, MISRAC++2023-21.2.4.
Coding standards
- MISRA C:2004 20.6
(Required) The macro offsetof in the stddef.h library shall not be used.
- MISRA C++ 2023 21.2.4
(Required) The macro offsetof shall not be used
Code examples
The following code example fails the check and will give a warning:
#include <stddef.h>
struct stat {
int st_size;
};
int example(void) {
return offsetof(struct stat, st_size);
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
}