[C++-sig] about std::wstring

Raul ro4tub at gmail.com
Sun Mar 19 13:51:15 CET 2006


Boost Version: 1.33.1
Compiler: VC7.1
OS: windows2000 sp4

when i write a c++ function:
void Foo(std::wstring str)
{
 wcout<<str<<endl;
}

then,called by the python script:
#python script
#dxui is my own defined  module
import dxui

def Bar():
 dxui.Foo(u"hello world")

at last,i called the 'Bar' function in my C++ code.

///.....

 try{

  logicNamespace["Bar"]();
 }catch(...)
 {
  if(PyErr_Occurred())
  {
   PyErr_Print();
  }
 }
///....

the following is the error:

Traceback (most recent call last):
  File "e:\work\TestUnicode\ui.py", line 5, in Bar
    dxui.Foo(u"hello world")
Boost.Python.ArgumentError: Python argument types in
    dxui.Foo(unicode)
did not match C++ signature:
    Foo(class std::basic_string<unsigned short,struct
std::char_traits<unsigned
short>,class std::allocator<unsigned short> >)

but in the 'initialize_builtin_converters'(builtin_converters.cpp)
function,i called.

# ifndef BOOST_NO_STD_WSTRING
    // Register by-value converters to std::string, std::wstring
    slot_rvalue_from_python<std::wstring, wstring_rvalue_from_python>();
# endif

yeah, in my platform ,it doesn't define the macro 'BOOST_NO_STD_WSTRING',
so what's wrong with it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060319/a8f5f89b/attachment.htm>


More information about the Cplusplus-sig mailing list