#ifndef not working

The following code will cause a segfault.

#include “/usr/lib/gcc/xb6_64-redhat-linux/4.1.1/include/stddef.h”

#ifndef offsetof
#define offsetof (TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

struct external_sun3_core
{
size_t c_regs;
};
struct internal_sunos_core
{
size_t c_regs_pos;
size_t c_regs_size;
};
static void swap(char * ext, struct internal_sunos_code *intcore)
{
struct external_sun3_core * extcore = (struct external_sun3_core *) ext;
intcode->c_regs_pos = offsetof(struct external_sun3_core, c_regs);
}

Patrick

The following code will cause a segfault.

#include "/usr/lib/gcc/xb6_64-redhat-linux/4.1.1/include/stddef.h"

#ifndef offsetof
#define offsetof (TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif

I'm pretty sure ifndef works. Can you elaborate on the problem you're hitting? I don't have "/usr/lib/gcc/xb6_64-redhat-linux/4.1.1/include/stddef.h". When I changed it to just #include "stddef.h", I get:

t.c:19:5: error: use of undeclared identifier 'intcode'
     intcode->c_regs_pos = offsetof(struct external_sun3_core, c_regs);
     ^
1 diagnostic generated.

with no crash.

-chris