Opened 16 years ago
Last modified 14 years ago
#207 closed defect
include/sys/cdefs.h needs updating for GCC 4.x — at Initial Version
Reported by: | psmedley | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.4 |
Component: | libc | Version: | 0.6.2 |
Severity: | normal | Keywords: | |
Cc: |
Description
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
cdefs.h diff