Bug #3637
closedwin32ole: Remove definition of NONAMELESSUNION in MinGW
Description
=begin
Hello,
I'm working in cross compiling Ruby to Windows (GCC) using moderm GCC versions, provided by mingw-w64 team targeting 32bits mode.
In this work, I found win32ole tries to define access to members of nameless union.
According to mingw-w64 developers, these hacks access were needed with older versions of GCC (prior 3.4) but nowdays are no longer required.
Looking at the source of these changes, dates 2002 (!) which is way before GCC 3.4
The following patch removes the definition of NONAMELESSUNION under MinGW and allows correct compilation under GCC 3.4.5, GCC 4.5.0 and cross-compilation under GCC 4.5.1 (experimental)
diff --git a/ext/win32ole/extconf.rb b/ext/win32ole/extconf.rb
index b4f09fc..d566be2 100644
--- a/ext/win32ole/extconf.rb
+++ b/ext/win32ole/extconf.rb
@@ -38,7 +38,7 @@ end
case RUBY_PLATFORM
when /mswin/
$CFLAGS += ' /W3'
-when /cygwin/, /mingw/
+when /cygwin/
$defs << '-DNONAMELESSUNION'
end
create_win32ole_makefile
mingw-w64 developers suggest a check for GCC version instead of NONAMELESSUNION definition.
I believe this also should be backported to 1.9.2, 1.9.1 and 1.8 branches.
Thank you.
=end
Updated by luislavena (Luis Lavena) over 14 years ago
=begin
Forgot to mention that with NONAMELESSUNION defined produces the following error:
ext/win32ole/win32ole.c: In function ‘ole_const_load’:
ext/win32ole/win32ole.c:2504:39: error: ‘VARDESC’ has no member named ‘u’
ext/win32ole/win32ole.c: In function ‘ole_usertype2val’:
ext/win32ole/win32ole.c:4541:44: error: ‘TYPEDESC’ has no member named ‘u’
ext/win32ole/win32ole.c: In function ‘ole_ptrtype2val’:
ext/win32ole/win32ole.c:4564:13: error: ‘TYPEDESC’ has no member named ‘u’
ext/win32ole/win32ole.c: In function ‘ole_variable_value’:
ext/win32ole/win32ole.c:6297:31: error: ‘VARDESC’ has no member named ‘u’
ext/win32ole/win32ole.c: In function ‘ole_param_flag_mask’:
ext/win32ole/win32ole.c:7373:9: error: ‘ELEMDESC’ has no member named ‘u’
ext/win32ole/win32ole.c: In function ‘ole_param_default’:
ext/win32ole/win32ole.c:7475:19: error: ‘ELEMDESC’ has no member named ‘u’
ext/win32ole/win32ole.c:7477:25: error: ‘ELEMDESC’ has no member named ‘u’
Since *DESC structures do not define the union in any way.
=end
Updated by suke (Masaki Suketa) over 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r28835.
Luis, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end
Updated by luislavena (Luis Lavena) over 14 years ago
=begin
Can this be backported to ruby_1_9_2 too? Thank you.
=end
Updated by mame (Yusuke Endoh) over 14 years ago
- Status changed from Closed to Open
=begin
Hi,
I was going to backport r28835, but I'm now afraid if it looks like
slightly wrong.
#if (defined(GNUC)) && (GNUC <= 3) && (GNUC_MINOR <= 4) && (GNUC_PATCHLEVEL <= 4)
This condition will be false when GCC version is 2.95.3, 3.3.5 or
3.3.6. Is it ok?
--
Yusuke Endoh mame@tsg.ne.jp
=end
Updated by luislavena (Luis Lavena) over 14 years ago
=begin
Hello Yusuke,
Indeed, my patch was more naive and just removed /mingw/ from the extension compilation process mainly since oldest MinGW available is 3.4.5.
Masaki committed this change. The inverse logic will not work with 4.5.0, 4.5.1 or 4.6.0.
=end
Updated by akr (Akira Tanaka) over 14 years ago
=begin
2010/8/6 Yusuke Endoh redmine@ruby-lang.org:
I was going to backport r28835, but I'm now afraid if it looks like
slightly wrong.#if (defined(GNUC)) && (GNUC <= 3) && (GNUC_MINOR <= 4) && (GNUC_PATCHLEVEL <= 4)
This condition will be false when GCC version is 2.95.3, 3.3.5 or
3.3.6. Is it ok?
I recommend something like the macro GCC_VERSION_SINCE in pack.c.¶
Tanaka Akira
=end
Updated by suke (Masaki Suketa) over 14 years ago
=begin
Hello,
On Fri, Aug 06, 2010 at 11:42:19PM +0900, Luis Lavena wrote:
Indeed, my patch was more naive and just removed /mingw/ from the extension compilation process mainly since oldest MinGW available is 3.4.5.
Masaki committed this change. The inverse logic will not work with 4.5.0, 4.5.1 or 4.6.0.
Sorry, I re-committed the version check logic of gcc.
(trunk revision 28894)
I tested mingw gcc 3.4.5 and cygwin gcc 3.4.4 and cygwin gcc 4.3.4.
Regards,
Masaki Suketa
=end
Updated by shyouhei (Shyouhei Urabe) about 14 years ago
- Status changed from Open to Closed
=begin
=end