Forum: Ruby MSC version unmatch

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
53fa2ca216f87747ebd8a44275eed121?d=identicon&s=25 unknown (Guest)
on 2006-12-24 00:06
(Received via mailing list)
So, I'm writing a program which uses SWIG to interface between C++ and
Ruby, and I just upgraded my Ruby version from an older version (I
think 1.8.2) to the current stable release (1.8.5).  Now when I compile
(in MSVS2003) I receive "fatal error C1189: #error :  MSC version
unmatch" from Ruby's config.h, from these lines:
#if _MSC_VER != 1200
#error MSC version unmatch
#endif
If I comment out these lines, I then get errors from ostream and
istream:
ostream(491) : warning C4003: not enough actual parameters for macro
'write'
ostream(490) : error C2059: syntax error : ')'
and so on.

Does anyone have a solution to this problem?
F1d6cc2b735bfd82c8773172da2aeab9?d=identicon&s=25 Nobuyoshi Nakada (Guest)
on 2006-12-24 05:38
(Received via mailing list)
Hi,

At Sun, 24 Dec 2006 08:05:05 +0900,
crysknife@gmail.com wrote in [ruby-talk:231120]:
> So, I'm writing a program which uses SWIG to interface between C++ and
> Ruby, and I just upgraded my Ruby version from an older version (I
> think 1.8.2) to the current stable release (1.8.5).  Now when I compile
> (in MSVS2003) I receive "fatal error C1189: #error :  MSC version
> unmatch" from Ruby's config.h, from these lines:
> #if _MSC_VER != 1200
> #error MSC version unmatch
> #endif

You can't mix ruby compiled with Visual C++ version 6 and
extensions compile with Visual C++ version 7 (MSVS2003), or
vice versa, due to the binary incompatibility between MSVC
runtime DLLs which those compilers use.

The only possible alternatives are:

a) compile your extension with VC6 (or mingw), or
b) compile ruby (and other extensions if you need) by yourself
   with VC7.
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jan Svitok (Guest)
on 2006-12-24 14:45
(Received via mailing list)
On 12/24/06, crysknife@gmail.com <crysknife@gmail.com> wrote:
> ostream(491) : warning C4003: not enough actual parameters for macro
> 'write'
> ostream(490) : error C2059: syntax error : ')'
> and so on.

You're facing two issues:
1. compiling extension with another compiler than ruby was compiled
with.
2. 1.8.5 has problems with stl, namely iostrem.

1. You may be lucky, and it might work. Just comment out the check.
DANGER!!! You may encounter strange bugs if you try! That being said,
for me it worked somehow (ruby VC6, ext VC8) - my extension is a
really thin layer that just copies memory chunks back and forth. I'm
not sure what the dangerous areas are, I remember hearing something
about files and errno.

If you can't compile your extension with VC6 or mingw, compiling ruby
+ oneclick installer with VC8 is a matter of a few hours. (I didn't
test too extensively the result, though). Just download the ruby
source tarball, read the readme in win32 dir, set your paths and start
whatever the readme tells you. One-click the same - checkout/export
trunk, and follow the readme. I had to download some things manually
from other sources, as their main site didn't work that time.

2. I had a similar problem. I got around it by #undef'ing write and
read before I #included <iostream>

Now that I think of it, I should have filed a bug... I have just done
that: #7431.
This topic is locked and can not be replied to.