An Octave user reported the following link error when building Octave on a Windows system with MinGW:
libtool: compile: g++ -shared-libgcc -DHAVE_CONFIG_H -I. -I../../../hg/octave-work/liboctave -I.. -Ic:/Programs/OctaveBuild/include -Ic:/Programs/WinDevTools/include -Ic:/Programs/GnuWin32/include -IC:/Programs/GnuWin32/include -I../libgnu -I../../../hg/octave-work/libgnu -I../../../hg/octave-work/libcruft/misc -Ic:/Programs/OctaveBuild/include -Ic:/Programs/WinDevTools/include -Ic:/Programs/GnuWin32/include -IC:/Programs/GnuWin32/include -O3 -fomit-frame-pointer -DHAVE_CONFIG_H -mieee-fp -I/WinDevTools/bin/../include/freetype2 -I/WinDevTools/bin/../include -IC:/Programs/WinDevTools/include -Wall -W -Wshadow -Wold-style-cast -Wformat -O3 -fomit-frame-pointer -O3 -fomit-frame-pointer -MT liboctave_la-CollocWt.lo -MD -MP -MF .deps/liboctave_la-CollocWt.Tpo -c ../../../hg/octave-work/liboctave/CollocWt.cc -DDLL_EXPORT -DPIC -o .libs/liboctave_la-CollocWt.o In file included from c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/cctype:44, from c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/bits/localefwd.h:44, from c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ios:42, from c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/ostream:40, from c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/iostream:40, from ../../../hg/octave-work/liboctave/CollocWt.cc:28: ../libgnu/wctype.h:218: error: previous declaration of 'wint_t rpl_towlower(wint_t)' with 'C++' linkage c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/ctype.h:215: error: conflicts with new declaration with 'C' linkage ../libgnu/wctype.h:225: error: previous declaration of 'wint_t rpl_towupper(wint_t)' with 'C++' linkage c:\programs\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include/ctype.h:216: error: conflicts with new declaration with 'C' linkage Adding an extern "C" block around the function declarations in ctype.in.h as in the attached patch solved the problem. Note that Octave is not including wctype.h directly, but via the C++ header cctype, so I would expect this to work without needing to surround the #include statement in the Octave sources with extern "C". jwe
>From 9c5eb4db02eaae3b8d2dc65a2a2c7e42b8aa8694 Mon Sep 17 00:00:00 2001 From: John W. Eaton <j...@gnu.org> Date: Thu, 7 Jan 2010 02:03:16 -0500 Subject: [PATCH] wctype.in.h: add extern "C" block for C++ --- ChangeLog | 4 ++++ lib/wctype.in.h | 8 ++++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92973cb..edd55bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-07 John W. Eaton <j...@octave.org> + + * lib/wctype.in.h: Add extern "C" block for C++. + 2010-01-06 Eric Blake <e...@byu.net> maint.mk: detect incorrect GFDL usage diff --git a/lib/wctype.in.h b/lib/wctype.in.h index 01a0779..7e8b090 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -62,6 +62,10 @@ # endif #endif +#ifdef __cplusplus +extern "C" { +#endif + /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. Linux libc5 has <wctype.h> and the functions but they are broken. Assume all 12 functions are implemented the same way, or not at all. */ @@ -227,5 +231,9 @@ rpl_towupper (wint_t wc) # endif +#ifdef __cplusplus +} +#endif + #endif /* _GL_WCTYPE_H */ #endif /* _GL_WCTYPE_H */ -- 1.6.5