Opened 15 years ago
Closed 13 years ago
#207 closed defect (fixed)
include/sys/cdefs.h needs updating for GCC 4.x
Reported by: | psmedley | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.4 |
Component: | libc | Version: | 0.6.2 |
Severity: | normal | Keywords: | |
Cc: |
Description (last modified by )
With the included cdefs.h, GCC 4.x breaks when building the JS code in mozilla with an error 'error: array bound is not an integer constant'
The problem comes from mozilla includes that use offsetof
cdefs.h needs to be updated for GCC 4.x, the following diff based on updated BSD headers fixes the problem:
--- u:\usr\include\sys\cdefs.h 2009-01-18 18:54:06.000000000 +0945 +++ u:\usr\local432\include\sys\cdefs.h 2009-01-18 18:55:24.000000000 +0945 @@ -251,9 +251,21 @@ * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> * require it. */ -#define __offsetof(type, field) ((size_t)(&((type *)0)->field)) -#define __rangeof(type, start, end) \ - (__offsetof(type, end) - __offsetof(type, start)) +#if __GNUC_PREREQ__(4, 1) +#define __offsetof(type, field) __builtin_offsetof(type, field) +#else +#ifndef __cplusplus +#define __offsetof(type, field) ((size_t)(&((type *)0)->field)) +#else +#define __offsetof(type, field) \ + (__offsetof__ (reinterpret_cast <size_t> \ + (&reinterpret_cast <const volatile char &> \ + (static_cast<type *> (0)->field)))) +#endif +#endif +#define __rangeof(type, start, end) \ + (__offsetof(type, end) - __offsetof(type, start)) + /* * Compiler-dependent macros to declare that functions take printf-like
Attachments (1)
Change History (5)
Changed 15 years ago by
Attachment: | cdefs.h.diff added |
---|
comment:2 Changed 13 years ago by
Description: | modified (diff) |
---|---|
Status: | new → assigned |
comment:3 Changed 13 years ago by
Note: See
TracTickets for help on using
tickets.
cdefs.h diff