U
user923005
If you expand your macro, so that the code does this, then you have
indeed violated the C language because that is very likely to fail.
#define offsetof(s, m) ((__char *) &((s *) 0)->m - (__char *) (s *) 0)On the other hand, if you simply use the offsetof() macro and trust your
implementation to implement it as it should then there is no violation
of the standard (indeed, if you do it any other way then you 'have a
screw loose').
Right, but...
Similarly,
may actually be implemented as:_asm INC EAX;which is not part of the C language, but why should I care? I am
responsible to write compliant code and the compiler is responsible to
translate it into machine instructions. Besides asking how does
offsetof() work, we may as well ask how malloc() works etc.
[...]
...my point was that the definition of offsetof must be in a way that is
accepted by the C compiler, and the definition of i++ or the definition
of malloc don't need to be.
And my point is that it is irrelevant if part of the C compiler is
accomplished in C or with something else.