stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r527386 - in /incubator/stdcxx/trunk/etc/config/src: LCONV.cpp STRUCT_TM.cpp
Date Wed, 11 Apr 2007 05:04:25 GMT
Author: sebor
Date: Tue Apr 10 22:04:24 2007
New Revision: 527386

URL: http://svn.apache.org/viewvc?view=rev&rev=527386
Log:
2007-04-10  Martin Sebor  <sebor@roguewave.com>

	STDCXX-393
	* STRUCT_TM.cpp (OFF): #defined a helper macro when the offsetof()
	macro from <stddef.h> doesn't work (i.e., when _RWSTD_NO_OFFSETOF
	is #defined).

Modified:
    incubator/stdcxx/trunk/etc/config/src/LCONV.cpp
    incubator/stdcxx/trunk/etc/config/src/STRUCT_TM.cpp

Modified: incubator/stdcxx/trunk/etc/config/src/LCONV.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/etc/config/src/LCONV.cpp?view=diff&rev=527386&r1=527385&r2=527386
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/LCONV.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/LCONV.cpp Tue Apr 10 22:04:24 2007
@@ -4,8 +4,18 @@
 #include <stddef.h>   // for offsetof, size_t
 #include <stdio.h>    // for printf
 #include <string.h>   // for strlen
+
 #include "config.h"
 
+#ifndef _RWSTD_NO_OFFSETOF
+#  define OFF(T, m)   offsetof (T, m)
+#else
+   // provide own equivalent when offsetof() macro doesn't work
+   // (e.g., when using the EDG eccp front end with an incompatible
+   // version of gcc)
+#  define OFF(T, m)   (((const char*)&((T*)0)->m) - ((const char*)(T*)0))
+#endif   // _RWSTD_NO_OFFSETOF
+
 // prevent IBM xlC 5.0 errors caused by using /usr/include/string.h
 // which #defines this (and other) names to undeclared symbols
 #undef strlen
@@ -21,7 +31,7 @@
     } lconv_info[] = {
 
 #define ENTRY(type, member, comment) { \
-        offsetof (lconv, member),      \
+        OFF (lconv, member),           \
         sizeof ((lconv*)0)->member,    \
         type,                          \
         # member,                      \

Modified: incubator/stdcxx/trunk/etc/config/src/STRUCT_TM.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/etc/config/src/STRUCT_TM.cpp?view=diff&rev=527386&r1=527385&r2=527386
==============================================================================
--- incubator/stdcxx/trunk/etc/config/src/STRUCT_TM.cpp (original)
+++ incubator/stdcxx/trunk/etc/config/src/STRUCT_TM.cpp Tue Apr 10 22:04:24 2007
@@ -5,6 +5,17 @@
 #include <string.h>   // for strlen
 #include <time.h>     // for struct tm
 
+#include "config.h"
+
+#ifndef _RWSTD_NO_OFFSETOF
+#  define OFF(T, m)   offsetof (T, m)
+#else
+   // provide own equivalent when offsetof() macro doesn't work
+   // (e.g., when using the EDG eccp front end with an incompatible
+   // version of gcc)
+#  define OFF(T, m)   (((const char*)&((T*)0)->m) - ((const char*)(T*)0))
+#endif   // _RWSTD_NO_OFFSETOF
+
 // prevent IBM xlC 5.0 errors caused by using /usr/include/string.h
 // which #defines these (and other) names to undeclared symbols
 #undef strlen
@@ -20,7 +31,7 @@
     } tm_info[] = {
 
 #define ENTRY(member, comment)   \
-        { offsetof (struct tm, member), # member ";", "   /* " comment " */" }
+        { OFF (struct tm, member), # member ";", "   /* " comment " */" }
 
         ENTRY (tm_sec,   "seconds after the minute [O..61] "),
         ENTRY (tm_min,   "minutes after the hour   [0..59] "),



Mime
View raw message