Bug #1346: Linkage errors compiling C++ extension with VC8
http://redmine.ruby-lang.org/issues/show/1346

Author: Miguel Muñoz
Status: Open, Priority: Normal
Target version: 1.9.1
ruby -v: ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32_80]

I've found two problems with extern "C" blocks while compiling some code generated by SWIG (the class example in the SWIG 1.3.39 distribution). I'm not sure if the problems came from Ruby or from SWIG, but I'd be grateful if someone can take a look at it.

The first error was:
...\microsoft visual studio 8\vc\platformsdk\include\wspiapi.h(44) : error C2894: templates cannot be declared to have 'C' linkage

I found a provisional workaround by modifying ruby-1.9.1-p0\include\ruby-1.9.1\ruby\win32.h, adding extern "C++" around some imports:

#if !defined(WSAAPI)
#ifdef __cplusplus
extern "C++"
{
#include <winsock2.h>
#include <ws2tcpip.h>
}
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#endif


The second error came from a Ruby file:
...\ruby-1.9.1-p0\include\ruby-1.9.1\ruby\missing.h(157) : error C2375: 'vsnprintf' : redefinition; different linkage
(...\microsoft visual studio 8\vc\include\stdio.h(333) : see declaration of 'vsnprintf')

For this one I just commented the vnsprintf function definition in missing.h:

//RUBY_EXTERN int vsnprintf(char *, size_t n, char const *, va_list);


Kind regards,

Miguel


----------------------------------------
http://redmine.ruby-lang.org