[cfe-dev] #ifndef not working
Chris Lattner
clattner at apple.com
Wed Aug 29 13:42:35 PDT 2007
On Aug 29, 2007, at 12:50 PM, Patrick Flannery wrote:
> 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
>
> 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
>
> Be a better Globetrotter. Get better travel answers from someone
> who knows.
> Yahoo! Answers - Check it out.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list