(C++) Where does offsetof come from?
exits funnel <[email protected]> Sun, 9 Jan 2005 16:55:58 -0800 (PST)
| Newsgroups | gmane.linux.redhat.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I'm trying to figure out where the offsetof macro is
defined? The following code:
// Begin code
#include <iostream.h>
#ifdef offsetof
#define foo 13
#else
#define foo 14
#endif
int main( )
{ cout << "foo = " << foo << endl; }
// End code
prints 13 so it would seem that there is an offsetof
macro defined somewhere. The only one I can find is
in /usr/include/linux/stddef.h but (A) according to
the output of g++ -v, this directory isn't in my
include path and (B) even if it were, I'm not
#including the file. Additionally, if I call offsetof
and run g++ -E it seems as though no substitution has
taken place. I would suspect that the offsetof
support is built right into the compiler but if that
were the case, shouldn't the code above print 14? I'm
using g++ version 3.2.3. If anyone could shed some
light upon where sizeof if defined I'd really
appreciate it.
-exits
__________________________________
Do you Yahoo!?
All your favorites on one personal page Try My Yahoo!
http://my.yahoo.com