# \[Bug:1.9\] compile error on win32ole with Mingw of MacPorts

**URL:** <https://www.ruby-forum.com/t/bug-1-9-compile-error-on-win32ole-with-mingw-of-macports/159769>\
**Category:** Development\
**Created:** [February 8, 2009, 3:44pm UTC](https://www.ruby-forum.com/t/bug-1-9-compile-error-on-win32ole-with-mingw-of-macports/159769 "2009-02-08T15:44:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [February 8, 2009, 3:44pm UTC](https://www.ruby-forum.com/t/bug-1-9-compile-error-on-win32ole-with-mingw-of-macports/159769/1 "2009-02-08T15:44:10Z")

</div>

e$B$J$+$@$G$9!#e(B

MacPortse$B$Ke(Bmingw-gcce$B$^$G$"$k$H$$$&$N$K6C$$$F;n$7$F$\_$?$N$G$9$,!“e(B  
win32olee$B$G%3%s%Q%$%k%(%i!\<$K$J$j$^$7$?!#BP1~$,8E$$$N$+!“e(B  
IMultiLanguage2e$B$I$3$m$+e(Bmlang.he$B$b$J$$$h$&$G$9!#e(Bwin32ole.ce$B$G$O0l8+e(B  
e$BBP1~$7$F$$$k$h$&$K8+$($^$9$,!”\<B:]$K$Oe(Bvoid\*e$B$r;H$&%3!\<%I$K$J$C$Fe(B  
e$B$7$^$&$?$a%3%s%Q%$%k$G$-$^$;$s!#e(BIMultiLanguagee$B$b$J$$$H$-$O0J2\<$Ne(B  
e$B$I$A$i$+$”$?$j$K$9$k$N$,$h$$$N$G$O$J$$$+$H;W$$$^$9!#e(B

(1) win32olee$B$O%3%s%Q%$%k$5$;$J$$e(B  
(2) e$B\<B9T;~$K\>o$K%(%i!\<$K$9$ke(B

extconf.rbe$B$Ge(Bexite$B$9$k$@$1$J$N$Ge(B(1)e$B$O\>JN,$7$^$9!#e(B(2)e$B$N%Q%C%A$r$D$1e(B  
e$B$^$9!#e(B

# Index: ext/win32ole/win32ole.c

— ext/win32ole/win32ole.c (revision 22130)  
+++ ext/win32ole/win32ole.c (working copy)  
@@ -24,5 +24,7 @@  
#include \<olectl.h\>  
#include \<ole2.h\>  
+#if defined(HAVE\_TYPE\_IMULTILANGUAGE2) ||  
defined(HAVE\_TYPE\_IMULTILANGUAGE)  
#include \<mlang.h\>  
+#endif  
#include \<stdlib.h\>  
#include \<math.h\>  
@@ -224,5 +226,5 @@ static IMultiLanguage2 \*pIMultiLanguage  
static IMultiLanguage \*pIMultiLanguage = NULL;  
#else  
-static void _pIMultiLanguage = NULL; /_ dummy _/  
+#define pIMultiLanguage NULL /_ dummy \*/  
#endif

@@ -286,6 +288,9 @@ static VALUE date2time\_str(double date);  
static rb\_encoding \*ole\_cp2encoding(UINT cp);  
static UINT ole\_encoding2cp(rb\_encoding \*enc);  
-static void load\_conv\_function51932();  
-static UINT ole\_init\_cp();  
+NORETURN(static void failed\_load\_conv51932(void));  
+#ifndef pIMultiLanguage  
+static void load\_conv\_function51932(void);  
+#endif  
+static UINT ole\_init\_cp(void);  
static char \*ole\_wc2mb(LPWSTR pw);  
static VALUE ole\_hresult2msg(HRESULT hr);  
@@ -977,5 +982,12 @@ static UINT ole\_encoding2cp(rb\_encoding

static void  
-load\_conv\_function51932()  
+failed\_load\_conv51932(void)  
+{

- rb\_raise(eWIN32OLERuntimeError, “fail to load convert function for  
CP51932”);  
+}
- 

+#ifndef pIMultiLanguage  
+static void  
+load\_conv\_function51932(void)  
{  
HRESULT hr = E\_NOINTERFACE;  
@@ -988,14 +1000,16 @@ load\_conv\_function51932()  
hr = CoCreateInstance(&CLSID\_CMultiLanguage, NULL,  
CLSCTX\_INPROC\_SERVER,  
&IID\_IMultiLanguage, &p);  
-#else

- hr = E\_NOINTERFACE;
- p = NULL;  
#endif  
if (FAILED(hr)) {
- 

```
 rb_raise(eWIN32OLERuntimeError, "fail to load convert function 

```

for CP51932");

- 

```
 failed_load_conv51932();

```

}  
pIMultiLanguage = p;  
}  
}  
+#else  
+#define load\_conv\_function51932() failed\_load\_conv51932()  
+#endif
- 

+#define conv\_51932(cp) ((cp) == 51932 && (load\_conv\_function51932(),  
1))

static void  
@@ -1013,9 +1027,9 @@ set\_ole\_codepage(UINT cp)  
case CP\_UTF7:  
case CP\_UTF8:

- 

```
       cWIN32OLE_cp = cp;

```

- 

```
       break;
   case 51932:
       cWIN32OLE_cp = cp;

```

- 

```
       if (cp == 51932) {

```

- 

```
           load_conv_function51932();

```

- 

```
       }

```

- 

```
       load_conv_function51932();
       break;
   default:

```

@@ -1029,5 +1043,5 @@ set\_ole\_codepage(UINT cp)

static UINT  
-ole\_init\_cp()  
+ole\_init\_cp(void)  
{  
UINT cp;  
@@ -1109,10 +1123,9 @@ ole\_wc2mb(LPWSTR pw)  
{  
LPSTR pm;

- HRESULT hr;  
int size = 0;
- DWORD dw = 0;
- if (cWIN32OLE\_cp == 51932) {
- load\_conv\_function51932();
- hr =  
pIMultiLanguage-\>lpVtbl-\>ConvertStringFromUnicode(pIMultiLanguage,

- if (conv\_51932(cWIN32OLE\_cp)) {  
+#ifndef pIMultiLanguage
- DWORD dw = 0;
- HRESULT hr =  
pIMultiLanguage-\>lpVtbl-\>ConvertStringFromUnicode(pIMultiLanguage,  
&dw, cWIN32OLE\_cp, pw, NULL, NULL, &size);  
if (FAILED(hr)) {  
@@ -1126,4 +1139,5 @@ ole\_wc2mb(LPWSTR pw)  
}  
pm[size] = ‘\0’;  
+#endif  
return pm;  
}  
@@ -1328,7 +1342,4 @@ ole\_vstr2wc(VALUE vstr)  
int size = 0;  
LPWSTR pw;

- int len = 0;
- DWORD dw = 0;
- HRESULT hr;  
st\_data\_t data;  
enc = rb\_enc\_get(vstr);  
@@ -1352,9 +1363,9 @@ ole\_vstr2wc(VALUE vstr)  
}  
}
- if (cp == 51932) {
- load\_conv\_function51932();
- len = RSTRING\_LEN(vstr);
- size = 0;
- hr = pIMultiLanguage-\>lpVtbl-\>ConvertStringToUnicode(pIMultiLanguage,

- if (conv\_51932(cp)) {  
+#ifndef pIMultiLanguage
- DWORD dw = 0;
- int len = RSTRING\_LEN(vstr);
- HRESULT hr =  
pIMultiLanguage-\>lpVtbl-\>ConvertStringToUnicode(pIMultiLanguage,  
&dw, cp, RSTRING\_PTR(vstr), &len, NULL, &size);  
if (FAILED(hr)) {  
@@ -1368,4 +1379,5 @@ ole\_vstr2wc(VALUE vstr)  
ole\_raise(hr, eWIN32OLERuntimeError, “fail to convert CP%d  
to Unicode”, cp);  
}  
+#endif  
return pw;  
}  
@@ -1381,12 +1393,10 @@ ole\_mb2wc(char \*pm, int len)  
int size = 0;  
LPWSTR pw;

- HRESULT hr;

- DWORD dw = 0;

- int n = len;

- if (cWIN32OLE\_cp == 51932) {

- load\_conv\_function51932();

- size = 0;

- hr = pIMultiLanguage-\>lpVtbl-\>ConvertStringToUnicode(pIMultiLanguage,

- if (conv\_51932(cWIN32OLE\_cp)) {  
+#ifndef pIMultiLanguage
- DWORD dw = 0;
- int n = len;
- HRESULT hr =  
pIMultiLanguage-\>lpVtbl-\>ConvertStringToUnicode(pIMultiLanguage,  
&dw, cWIN32OLE\_cp, pm, &n, NULL, &size);  
if (FAILED(hr)) {  
@@ -1399,4 +1409,5 @@ ole\_mb2wc(char \*pm, int len)  
ole\_raise(hr, eWIN32OLERuntimeError, “fail to convert CP%d  
to Unicode”, cWIN32OLE\_cp);  
}  
+#endif  
return pw;  
}

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [February 9, 2009, 12:20am UTC](https://www.ruby-forum.com/t/bug-1-9-compile-error-on-win32ole-with-mingw-of-macports/159769/2 "2009-02-09T00:20:33Z")

</div>

e$BCfEDe(B e$B?-1Ye(B wrote:

> extconf.rbe$B$Ge(Bexite$B$9$k$@$1$J$N$Ge(B(1)e$B$O\>JN,$7$^$9!#e(B(2)e$B$N%Q%C%A$r$D$1e(B  
> e$B$^$9!#e(B

e$B%3%\_%C%H$7$F$$$?$@$1$^$9$+!)e(B

e$B$H$3$m$G!"$h$/$o$+$C$F$J$$$N$G$9$,!"e(BMacPorts(e$B!)e(B)e$B$N4D6-$Ge(B  
win32olee$B$C$FF0:n$9$k$b$N$J$s$G$7$g$&$+!)e(B

e$B85!9!"e(BIMultiLanguagee$B$,$J$/$Fe(Bwin32olee$B$,F0$/4D6-$H$$$&$N$re(B  
e$B$A$c$s$HA[Dj$7$F$J$+$C$?$N$G!"CfESH\>C\<$JBP1~$K$J$C$F$$$?$H;W$$$^$9!#e(B

e$B=uEDe(B e$B2m5\*e(B

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [February 9, 2009, 12:17pm UTC](https://www.ruby-forum.com/t/bug-1-9-compile-error-on-win32ole-with-mingw-of-macports/159769/3 "2009-02-09T12:17:30Z")

</div>

e$B%A%1%C%He(B #1132 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!\<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B  
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

## Applied in changeset r22180.

[http://redmine.ruby-lang.org/issues/show/1132](http://redmine.ruby-lang.org/issues/show/1132)

---

<div class="post-metadata">

**Author:** ![nobu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e9c0ed/32.png) [@nobu](https://www.ruby-forum.com/u/nobu)\
**Post date:** [February 9, 2009, 12:34pm UTC](https://www.ruby-forum.com/t/bug-1-9-compile-error-on-win32ole-with-mingw-of-macports/159769/4 "2009-02-09T12:34:39Z")

</div>

e$B$J$+$@$G$9!#e(B

At Mon, 9 Feb 2009 08:19:01 +0900,  
Masaki S. wrote in [ruby-dev:37953]:

> e$B$H$3$m$G!"$h$/$o$+$C$F$J$$$N$G$9$,!"e(BMacPorts(e$B!)e(B)e$B$N4D6-$Ge(B  
> win32olee$B$C$FF0:n$9$k$b$N$J$s$G$7$g$&$+!)e(B
> 
> e$B85!9!"e(BIMultiLanguagee$B$,$J$/$Fe(Bwin32olee$B$,F0$/4D6-$H$$$&$N$re(B  
> e$B$A$c$s$HA[Dj$7$F$J$+$C$?$N$G!"CfESH\>C\<$JBP1~$K$J$C$F$$$?$H;W$$$^$9!#e(B

winee$B$b$"$k$N$G$9$,!"e(B  
$ wine …/i386-mingw32/ruby -v  
err:ntdll:RtlpWaitForCriticalSection section 0x6034c698 “?” wait timed  
out in thread 0009, blocked by 0000, retrying (60 sec)  
…

e$B$H%k!\<%W$7$F$7$^$$$^$9!#$H$$$&$o$1$G!"8=\>u$G$O%/%m%9%3%s%Q%$%k$@e(B  
e$B$1$G$9!#e(B
