From e5d4845a5b7f20c0c0711ca96ff984094739ae88 Mon Sep 17 00:00:00 2001 From: Luis Lavena Date: Sun, 12 Sep 2010 17:58:16 -0300 Subject: [PATCH 3/3] Fix NONAMELESSUNION win32ole issues by manually backport r28835 and r28894 --- ext/win32ole/extconf.rb | 2 -- ext/win32ole/win32ole.c | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb index cee9225..565964c 100644 --- a/ext/win32ole/extconf.rb +++ b/ext/win32ole/extconf.rb @@ -35,7 +35,5 @@ end case RUBY_PLATFORM when /mswin32/ $CFLAGS += ' /W3' -when /cygwin/, /mingw/ - $defs << '-DNONAMELESSUNION' end create_win32ole_makefile diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 8d37c35..81bda8c 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -17,6 +17,18 @@ #include "ruby.h" #include "st.h" + +#define GNUC_OLDER_3_4_4 \ + ((__GNUC__ < 3) || \ + ((__GNUC__ <= 3) && (__GNUC_MINOR__ < 4)) || \ + ((__GNUC__ <= 3) && (__GNUC_MINOR__ <= 4) && (__GNUC_PATCHLEVEL__ <= 4))) + +#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) +#ifndef NONAMELESSUNION +#define NONAMELESSUNION 1 +#endif +#endif + #include #include #include @@ -36,13 +48,13 @@ #define DOUTI(x) fprintf(stderr, "[%ld]:" #x "=%d\n",__LINE__,x) #define DOUTD(x) fprintf(stderr, "[%d]:" #x "=%f\n",__LINE__,x) -#if defined NONAMELESSUNION && __GNUC__ +#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) #define V_UNION1(X, Y) ((X)->u.Y) #else #define V_UNION1(X, Y) ((X)->Y) #endif -#if defined NONAMELESSUNION && __GNUC__ +#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) #undef V_UNION #define V_UNION(X,Y) ((X)->n1.n2.n3.Y) -- 1.7.2.3