Ogre3D with OgreBullet - ogre

Actual problem
I'm working with Ogre3D 1.7 and I am trying to build the OgreBullet library (wrapper for the Bullet 2.82 Physics librairy) but I've got some casting errors :
1>..\..\src\OgreBulletCollisionsRay.cpp(87): error C2664: 'OgreBulletCollisions::Object *OgreBulletCollisions::CollisionsWorld::findObject(Ogre::SceneNode *) const' : impossible de convertir le paramètre 1 de 'const btCollisionObject *' en 'Ogre::SceneNode *'
I didn't modify the code so I do not understand why it can't compile ? Did someone had this error ?
EDIT (previous errors resolved):
If you have this error
1>..\..\src\OgreBulletCollisionsWorld.cpp(226): error C2440: 'static_cast' : impossible de convertir de 'const btCollisionObject *' en 'btCollisionObject *'
Try replacing static_cast by const_cast in the following lines :
btCollisionObject* obA = const_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = const_cast<btCollisionObject*>(contactManifold->getBody1());

Related

How to pass time_t by reference into a function

I have a function definition like this:
double getPriceTimeByPtr(const StrategyParams* ptr, const int applied_price, const int timeframe, const int shift, const int shift_delta, const bool normalized, time_t &time);
but when I compile this code it errors just before the &time part so clearly there is a problem passing a time_t object by reference.
How do I fix this please?
I recently added the time_t parameter to the function and the error occurred since then.
Here's the errors generated:
Severity Code Description Project File Line Suppression
State
Error C2143 syntax error: missing ')' before '&'
Error C2143 syntax error: missing '{' before '&'
Error C2059 syntax error: '&'
Error C2059 syntax error: ')'
The syntax seems correct to me but the compiler doesn't like it.
The project that was failing was defined as a C project which was then trying to call a C++ function by reference. C can't us by reference so was failing. Changing the time parameters to pointers worked.

Multiple errors when compiling wxWidgets with gcc 4.8.1

I've been trying for a while now compile wxWidgets library for Code::Blocks and I am still getting a lot of different errors.
My gcc verions is: gcc (tdm-2) 4.8.1 and I want to build newest wxWidgets: 3.1.0. I've tried 3 different sources and each time I have some error (sometimes this same, sometimes different). I am working on Windows 8.1.
[1]mingw32-make -f makefile.gcc UNICODE=1 MONOLITHIC=1 SHARED=1 BUILD=debug CXXFLAGS="-std=gnu++11"
and the error output:
../../src/common/wxcrt.cpp: In function 'int wxVsprintf(wchar_t*, const wxString
&, va_list)':
../../src/common/wxcrt.cpp:623:47: error: invalid conversion from 'const wchar_t
*' to 'size_t {aka unsigned int}' [-fpermissive]
return wxCRT_VsprintfW(str, format.wc_str(), argptr);
^
../../src/common/wxcrt.cpp:623:56: error: cannot convert 'va_list {aka char*}' t
o 'const wchar_t*' for argument '3' to 'int vswprintf(wchar_t*, size_t, const wc
har_t*, char*)'
return wxCRT_VsprintfW(str, format.wc_str(), argptr);
^
../../src/common/wxcrt.cpp:632:1: warning: control reaches end of non-void funct
ion [-Wreturn-type]
}
^
makefile.gcc:6786: recipe for target 'gcc_mswuddll\monodll_wxcrt.o' failed
mingw32-make: *** [gcc_mswuddll\monodll_wxcrt.o] Error 1
[2]mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=debug and the error output:
../../src/common/wxcrt.cpp: In function 'int wxVsprintf(wchar_t*, const wxString
&, va_list)':
../../src/common/wxcrt.cpp:623:47: error: invalid conversion from 'const wchar_t
*' to 'size_t {aka unsigned int}' [-fpermissive]
return wxCRT_VsprintfW(str, format.wc_str(), argptr);
^
../../src/common/wxcrt.cpp:623:56: error: cannot convert 'va_list {aka char*}' t
o 'const wchar_t*' for argument '3' to 'int vswprintf(wchar_t*, size_t, const wc
har_t*, char*)'
return wxCRT_VsprintfW(str, format.wc_str(), argptr);
^
../../src/common/wxcrt.cpp:632:1: warning: control reaches end of non-void funct
ion [-Wreturn-type]
}
^
makefile.gcc:11860: recipe for target 'gcc_mswuddll\basedll_wxcrt.o' failed
mingw32-make: *** [gcc_mswuddll\basedll_wxcrt.o] Error 1
[3]mingw32-make -f makefile.gcc USE_XRC=1 SHARED=1 MONOLITHIC=1 BUILD=release UNICODE=1 USE_OPENGL=1 VENDOR=cb CXXFLAGS="-fno-keep-inline-dllexport"1 and the error:
../../src/common/wxcrt.cpp: In function 'int wxVsprintf(wchar_t*, const wxString
&, va_list)':
../../src/common/wxcrt.cpp:623:47: error: invalid conversion from 'const wchar_t
*' to 'size_t {aka unsigned int}' [-fpermissive]
return wxCRT_VsprintfW(str, format.wc_str(), argptr);
^
../../src/common/wxcrt.cpp:623:56: error: cannot convert 'va_list {aka char*}' t
o 'const wchar_t*' for argument '3' to 'int vswprintf(wchar_t*, size_t, const wc
har_t*, char*)'
return wxCRT_VsprintfW(str, format.wc_str(), argptr);
^
../../src/common/wxcrt.cpp:632:1: warning: control reaches end of non-void funct
ion [-Wreturn-type]
}
^
makefile.gcc:6786: recipe for target 'gcc_mswudll\monodll_wxcrt.o' failed
mingw32-make: *** [gcc_mswudll\monodll_wxcrt.o] Error 1
Can someone please advice me what more I can do?
I'm not sure why are you speaking about multiple errors, this is clearly one and the same error and is due to using standard-like vswprintf() instead of the function from MSVC CRT which is normally used by MinGW by default. The former should only be used when __USE_MINGW_ANSI_STDIO is in effect and it's very strange that you still get it without it, I wonder if you have CPPFLAGS or similar set in your environment?
Anyhow, I'd recommend using TDM-GCC 4.9 as 3.1.0 definitely compiles with it (this is what the official binaries have been built with). 4.8 is supposed to work too, of course, so it could be worth checking how is __USE_MINGW_ANSI_STDIO getting defined, but installing 4.9 will probably be simpler for you.

C2664 Cannot convert parameter 1 from 'int' to 'hwnd'

Im trying to make a simple program for a old pocketpc application.
Want it to get the time and show it when i use the pushbutton.
With the code below, i get two compiler errors:
error C2664: 'SetWindowTextW' : cannot convert parameter 1 from 'int' to 'HWND' Line: 201
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR' Line: 233
Ive tried to search, seems to be a common misunderstanding this, but i cant see an explanation that fits..
_strdate( dateStr);
SetWindowText(1003, dateStr);
Also this:
hwndLabel = CreateWindow("STATIC","Time",
WS_VISIBLE | WS_CHILD | SS_RIGHT,
10,200,75,35,hWnd,NULL,1003,NULL);
Edit:
After Xearinox suggestions, i get three new faults.
These:
error C2664: '_wstrdate' : cannot convert parameter 1 from 'char [9]' to 'wchar_t *' 199
error C2664: 'SetDlgItemTextW' : cannot convert parameter 3 from 'char [9]' to 'LPCWSTR' 201
error C2440: '=' : cannot convert from 'HWND' to 'int' 233
if i remove (HMENU) from the static, i get another last error:
error C2664: 'CreateWindowExW' : cannot convert parameter 10 from 'int' to 'HMENU' 233
First parameter of SetWindowText is hwnd, not control identifier.
Try this:
SetDlgItemTextW(hWnd, 1003, dateStr);
Use this for retrieve date:
WCHAR dateStr[256] = {0};
_wstrdate(dateStr);
Also use wide string parameters for CreateWindow:
hwndLabel = CreateWindowW(L"STATIC",L"Time",
WS_VISIBLE | WS_CHILD | SS_RIGHT,
10,200,75,35,hWnd, (HMENU)1003, NULL, NULL);

cannot convert parameter from 'PCHAR' to 'LPCWSTR'

I have defined the pointer size_Drive as :
PCHAR size_Drive ;
then i used the function lstrlen :
size_Drive += (lstrlen(size_Drive) + 1) ; (line 28)
but it gives me the following ERROR :
1>c:\users\hp.hp-pc\documents\visual studio 2008\projects\getvolumeinfo\getvolumeinfo\getvolumeinfo.cpp(28) : error C2664: 'lstrlenW' : cannot convert parameter 1 from 'PCHAR' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
PCHAR is a typedef for char whereas LPCWSTR is a typedef for const wchar_t*, and in a Unicode build lstrlen is a macro for the Unicode function lstrlenW.
You should call lstrlenA specifically to use the ANSI function.

Error 4 error C2440: 'initializing' : cannot convert from 'void *' to 'char *'

I tried to compile this and got mistakes such as:
Error 4 error C2440: 'initializing' : cannot convert from 'void *' to 'char *'
This code is taken from here. Why doesn't it work?
DWORD dwRead=0;
char *lpData = (VOID*)GlobalAlloc(GMEM_FIXED, MAX_READ),
You appear to be compiling with a C++ compiler, so you'll need an explicit cast:
char *lpData = (char *)GlobalAlloc(GMEM_FIXED, MAX_READ);

Resources