In the past I'd run across some contradictory recommendations regarding the standard macro offsetof. I happened upon a use for it in some code I am developing, but was wary of distant memories.
In the MISRA guidlines, summarized for Jean LaBrosee's Micro-C/OS-II, it states the following for Rule 120 (page 7).And in another piece I found while searching the web, there is this.The macro offsetof, in library <stddef.h>, shall not be used.I'd surfed comp.lang.c and found some information (which is as fun as always to interpret), but I am wondering if anyone here has any input regarding the use of offsetof? Why did MISRA give it a "shall not be used"? Are there other considerations besides portability?Rule 120: The offsetof macro is a portable method of obtaining the offset of a struct member. The only undefined behavior applies to bit-fields.
This rule should state: 'The use of offsetof is recommended.'