This is a very simple error, but I don't understand how it can happen. I have two variables named sipRes, both are contained in separate If... statements. First one is a bool, second is a pointer (PyObject*), but MSVC9 compiler is throwing me an error at what (I think) should be valid C++ code:
107: error: C2440: '=' : cannot convert from 'bool' to 'PyObject *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Line 107 is when I set the result of sipConvertFromNewType (which returns a PyObject*) to sipRes, which was declared as PyObject*, but the compiler seems to be ignoring it and thinks it's a bool instead. What is wrong here?? Am I missing a compiler flag?
This is mostly autogenerated code, so it's not as simple as naming it sipRes2.
Below is part of my Makefile, and the offending function code
107: error: C2440: '=' : cannot convert from 'bool' to 'PyObject *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Line 107 is when I set the result of sipConvertFromNewType (which returns a PyObject*) to sipRes, which was declared as PyObject*, but the compiler seems to be ignoring it and thinks it's a bool instead. What is wrong here?? Am I missing a compiler flag?
This is mostly autogenerated code, so it's not as simple as naming it sipRes2.
Below is part of my Makefile, and the offending function code
Code:
CC = cl
CXX = cl
LINK = link
CPPFLAGS = -DNDEBUG -DWIN32 -DQT_LARGEFILE_SUPPORT -DMBCS -DQT_DLL -DQT_NO_DEBUG -I. -I$(VOICEMANAGERDIR)\include -I$(OPALDIR)\include -I$(PTLIBDIR)\include -I$(QTDIR)\include\QtCore -IC:\Python27\include -IC:\Qt\2010.05\qt\mkspecs\default -IC:\Qt\2010.05\qt\include\voicemanager -IC:\Qt\2010.05\qt\include\opal -IC:\Qt\2010.05\qt\include\ptlib -IC:\Qt\2010.05\qt\include
CFLAGS = -Zi -nologo -Zm200 -Zc:wchar_t -Zc:forScope -O2 -MD -W3
CXXFLAGS = -EHsc -Zi -nologo -Zm200 -Zc:wchar_t -Zc:forScope -O2 -MD -W3 -w34100 -w34189
LFLAGS = /DEBUG /PDB:pyvoicemanager.pdb /NOLOGO /DLL /MANIFEST /MANIFESTFILE:$(TARGET).manifest /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /INCREMENTAL:NO
LIBS = /LIBPATH:$(VOICEMANAGERDIR)\lib /LIBPATH:$(OPALDIR)\lib /LIBPATH:$(PTLIBDIR)\lib /LIBPATH:C:\Python27\libs /LIBPATH:C:\Qt\2010.05\qt\lib python27.lib voicemanager.lib opal.lib ptlib.lib
MOC = C:\Qt\2010.05\qt\bin\\moc.exe
.SUFFIXES: .c .cpp .cc .cxx .C
Code:
static PyObject *meth_OpalTransportAddress_GetIpAndPort(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
PyObject *sipParseErr = NULL;
{
PIPSocket::Address * a0;
WORD a1;
OpalTransportAddress *sipCpp;
if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, NULL, NULL, "B", &sipSelf, sipType_OpalTransportAddress, &sipCpp))
{
PBoolean sipRes; // first sipRes var
a0 = new PIPSocket::Address();
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->GetIpAndPort(*a0,a1);
Py_END_ALLOW_THREADS
return sipBuildResult(0,"(bNt)",sipRes,a0,sipType_PIPSocket_Address,NULL,a1);
}
}
{
OpalTransportAddress *sipCpp;
if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, NULL, NULL, "B", &sipSelf, sipType_OpalTransportAddress, &sipCpp))
{
PyObject * sipRes = 0; //second sipRes var
sipErrorState sipError = sipErrorNone;
#line 101 "C:\\iPhoneDev\\voicemanager\\sip\\opal/OpalTransport.sip"
PIPSocketAddressAndPort * ipPort = new PIPSocketAddressAndPort;
Py_BEGIN_ALLOW_THREADS
sipCpp->GetIpAndPort(*ipPort);
Py_END_ALLOW_THREADS
if ((sipRes=sipConvertFromNewType(ipPort, sipType_PIPSocketAddressAndPort, NULL) == NULL))
{
sipError=sipErrorFail;
PyErr_SetString(PyExc_RuntimeError, "Failed to convert C++ Object to PyObject");
}
#line 280 "C:\\iPhoneDev\\voicemanager\\sip\\build\\opal\\release/sippyopalOpalTransportAddress.cpp"
if (sipError == sipErrorFail)
return 0;
if (sipError == sipErrorNone)
{
return sipRes;
}
sipAddException(sipError, &sipParseErr);
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_OpalTransportAddress, sipName_GetIpAndPort, NULL);
return NULL;
}