[Python-Dev] unicode objects and C++

Mark Hammond mhammond@skippinet.com.au
Tue, 14 Mar 2000 12:18:45 +1100


I struck a bit of a snag with the Unicode support when trying to use the
most recent update in a C++ source file.

The problem turned out to be that unicodeobject.h did a #include "wchar.h",
but did it while an 'extern "C"' block was open.  This upset the MSVC6
wchar.h, as it has special C++ support.

Attached below is a patch I made to unicodeobject.h that solved my problem
and allowed my compilations to succeed.  Theoretically the same problem
could exist for wctype.h, and probably lots of other headers, but this is
the immediate problem :-)

An alternative patch would be to #include "whcar.h" in PC\config.h outside
of any 'extern "C"' blocks - wchar.h on Windows has guards that allows for
multiple includes, so the unicodeobject.h include of that file will succeed,
but not have the side-effect it has now.

Im not sure what the preferred solution is - quite possibly the PC\config.h
change, but Ive include the unicodeobject.h patch anyway :-)

Mark.

*** unicodeobject.h	2000/03/13 23:22:24	2.2
--- unicodeobject.h	2000/03/14 01:06:57
***************
*** 85,91 ****
--- 85,101 ----
  #endif

  #ifdef HAVE_WCHAR_H
+
+ #ifdef __cplusplus
+ } /* Close the 'extern "C"' before bringing in system headers */
+ #endif
+
  # include "wchar.h"
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
  #endif

  #ifdef HAVE_USABLE_WCHAR_T