Bug #3637

win32ole: Remove definition of NONAMELESSUNION in MinGW

Added by Luis Lavena about 5 years ago. Updated over 4 years ago.

[ruby-core:31567]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 1.9.3dev (2010-07-31 trunk 28808) [i386-mingw32] Backport:

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

Associated revisions

Revision 28835
Added by Masaki Suketa about 5 years ago

  • ext/win32ole/win32ole.c: NONAMELESSUNION defined only if gcc version is older than 3.4.4. [Bug #3637]
  • ext/win32ole/extconf.rb: ditto.

Revision 28835
Added by Masaki Suketa about 5 years ago

  • ext/win32ole/win32ole.c: NONAMELESSUNION defined only if gcc version is older than 3.4.4. [Bug #3637]
  • ext/win32ole/extconf.rb: ditto.

History

#1 Updated by Luis Lavena about 5 years ago

=begin
Forgot to mention that with NONAMELESSUNION defined produces the following error:

http://gist.github.com/499840

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

#2 Updated by Masaki Suketa about 5 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

#3 Updated by Luis Lavena about 5 years ago

=begin
Can this be backported to ruby_1_9_2 too? Thank you.
=end

#4 Updated by Yusuke Endoh about 5 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

#5 Updated by Luis Lavena about 5 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

#6 Updated by Akira Tanaka about 5 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

#7 Updated by Masaki Suketa about 5 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

#8 Updated by Shyouhei Urabe about 5 years ago

  • Status changed from Open to Closed

=begin

=end

Also available in: Atom PDF