error: invalid conversion from 'int' to 'const wchar_t*'

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

Code: Select all

Irrlicht 1.7.2
 
||=== Irrlicht Example 21 Quake 3 Explorer, Windows ===|
warning: missing initializer for member 'SItemElement::model'|
warning: missing initializer for member 'SItemElement::sound'|
warning: missing initializer for member 'SItemElement::icon'|
warning: missing initializer for member 'SItemElement::pickup'|
warning: missing initializer for member 'SItemElement::value'|
warning: missing initializer for member 'SItemElement::group'|
warning: missing initializer for member 'SItemElement::sub'|
warning: missing initializer for member 'SItemElement::special'|
main.cpp||In member function 'void CQuake3EventHandler::addSceneTreeItem(irr::scene::ISceneNode*, irr::gui::IGUITreeViewNode*)':|
error: invalid conversion from 'int' to 'const wchar_t*'|
error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
error: invalid conversion from 'int' to 'const wchar_t*'|
error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
error: invalid conversion from 'int' to 'const wchar_t*'|
error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
 
 
 
 
main.cpp||In member function 'void CQuake3EventHandler::Animate()':|
 
 
 
error: invalid conversion from 'int' to 'const wchar_t*'|
error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
error: invalid conversion from 'int' to 'const wchar_t*'|
error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
||=== Build finished: 10 errors, 8 warnings ===|
 
that is the result from compiling tutorial n.21 (Quake map explorer), I discovered it when (literally) pulling my hair in frustration over my code malfunctioning with no obvious solution, I decided to compile the tutorial (INCLUDED in the download... of irrlicht 1.7.2)
and well, it confirmed what I thought, my code is correct, at least to the extent that the tutorial taught me.

I have now spent several days non-stop debugging my code to no avail.
same errors.

thus, it is either a bug in irrlicht....

OR

the tutorials are horribly OUTDATED.

just wanted to shed some light on this.....

:evil:

now, any solution, workaround or simmilar?
I cannot continue my project unless I get some idea what's causing this.

and yes, I did check the wiki, API tutorials (over and over) Google and other search engines (for hours)...
Last edited by Cube_ on Wed Nov 16, 2011 8:05 pm, edited 1 time in total.
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

What kind of compiler do you use that doesn't even give line-numbers for the errors? I haven't heard so far that anyone had trouble compiling the examples coming with Irrlicht 1.7.2 and compiled them myself on several platforms.

So not sure right now - either this is a new bug recently added - so first question: Which Irrlicht version do you use: The official 1.7.2 download, svn trunk or svn release branch 1.7?
Next question: Which compiler are you using? Maybe a newer compiler has some harsher restrictions for conversions. Also please tell which OS.
Next: You really compiled the example coming with Irrlicht - using project files coming with it? Not for example tutorials copied from the website (I think those are outdated)?
Lastly: Could you have some version mixup - like accidentally using Irrlicht headers from another Irrlicht version (check the include path in your IDE).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

edited out... (not on purpose, happened whe removing the file path)

official download
compiler
tried BOTH
VC 2008 express and mingw(gcc port)

Win XP pro. (Could also try on my Ubuntu 11.04 machine)

I took the ones that came with the download. so yes, not the ones from the website.

No, I only have irrlicht 1.7.2 on my computer, double checked all include paths.
"this is not the bottleneck you are looking for"
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by serengeor »

I can confirm this problem, It happens on svn version too (about month haven't updated it, but still). I used mingw to compile on win7.
Simple type casting to wchar_t does the job, though I don't know if it's good to do that.
Working on game: Marrbles (Currently stopped).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

Sorry, I just downloaded it again, compiled it in VS Express 2008 on Windows XP and it compiles.

Lets start with VS Express 2008.

Your problem there seems to be that for some reason the following line in irrTypes.h is not compiled in your case:

Code: Select all

 
#define swprintf swprintf_s
 
To test if that's really the problem please just copy that line below your includes in your source-file. Then check again if it compiles.

If so then lets figure out why it didn't compile for you before. Compile the following (just like that):

Code: Select all

 
#ifdef _IRR_WINDOWS_API_
compile error A
#if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
compile error B
#endif
#endif
 
Then please tell me which of the 2 compile errors you got.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

Code: Select all

||=== Irrlicht Example 21 Quake 3 Explorer, Windows ===|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|11|warning: "swprintf" redefined|
..\..\include\irrTypes.h|101|note: this is the location of the previous definition|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::model'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::sound'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::icon'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::pickup'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::value'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::group'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::sub'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::special'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp||In function 'void Q3ShaderFactory(irr::scene::quake3::Q3LevelLoadParameter&, irr::IrrlichtDevice*, irr::scene::IQ3LevelMesh*, irr::scene::quake3::eQ3MeshIndex, irr::scene::ISceneNode*, irr::scene::IMetaTriangleSelector*, bool)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|407|error: 'swprintf_s' was not declared in this scope|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp||In function 'void Q3ModelFactory(irr::scene::quake3::Q3LevelLoadParameter&, irr::IrrlichtDevice*, irr::scene::IQ3LevelMesh*, irr::scene::ISceneNode*, bool)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|644|error: 'swprintf_s' was not declared in this scope|
||=== Build finished: 3 errors, 9 warnings ===|
 
in irrTypes.h:

Code: Select all

#if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
#define swprintf swprintf_s
#define snprintf sprintf_s
#else
#define swprintf _snwprintf
#define snprintf _snprintf
#endif
didn't help.
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

Well, it did help in some way - you have a new error-message.
Please add before the define:
#include <wchar.h>

edit: Also please do that other test - the one with the defines. Just replace your whole main for a moment with those lines I posted above and tell if you get a compile error.

edit2: Also just to be sure - use VS Express for now. This line is one that behaves different in gcc and VS. Lets figure them out one at a time.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

sure!


replacing the whole main file with the other test gave this

Code: Select all

||=== Irrlicht Example 21 Quake 3 Explorer, Windows ===|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp||In member function 'void CQuake3EventHandler::addSceneTreeItem(irr::scene::ISceneNode*, irr::gui::IGUITreeViewNode*)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|1157|error: invalid conversion from 'int' to 'const wchar_t*'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|1157|error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|1161|error: invalid conversion from 'int' to 'const wchar_t*'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|1161|error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|1173|error: invalid conversion from 'int' to 'const wchar_t*'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|1173|error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp||In member function 'void CQuake3EventHandler::Animate()':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|2041|error: invalid conversion from 'int' to 'const wchar_t*'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|2041|error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|2048|error: invalid conversion from 'int' to 'const wchar_t*'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\main.cpp|2048|error:   initializing argument 2 of 'int swprintf(wchar_t*, const wchar_t*, ...)'|
||=== Build finished: 10 errors, 0 warnings ===|
 
and the #include<wchar.h> gave this:

Code: Select all

r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|11|warning: "swprintf" redefined|
..\..\include\irrTypes.h|101|note: this is the location of the previous definition|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::model'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::sound'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::icon'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::pickup'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::value'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::group'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::sub'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::special'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp||In function 'void Q3ShaderFactory(irr::scene::quake3::Q3LevelLoadParameter&, irr::IrrlichtDevice*, irr::scene::IQ3LevelMesh*, irr::scene::quake3::eQ3MeshIndex, irr::scene::ISceneNode*, irr::scene::IMetaTriangleSelector*, bool)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|407|error: 'swprintf_s' was not declared in this scope|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp||In function 'void Q3ModelFactory(irr::scene::quake3::Q3LevelLoadParameter&, irr::IrrlichtDevice*, irr::scene::IQ3LevelMesh*, irr::scene::ISceneNode*, bool)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|644|error: 'swprintf_s' was not declared in this scope|
||=== Build finished: 3 errors, 9 warnings ===|
 
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

aaammmsterdddam wrote:sure!
replacing the whole main file with the other test gave this
<snip>
That can obviously not be. If you replace the main file with my code from above you can't get errors in lines which are not even there anymore. You posted an error in line 1157 for what should be now a 7 line long main file...

edit: Also I hope you try to understand what is going on here. Your problem is that Microsoft implemented swprintf different than the GNU people did. Same function name - but functions which have different parameters (not sure who to blame here - the person who implemented it later on but slightly different should probably be shot on the spot). So Irrlicht is replacing the usual swprintf implementation from Microsoft with their swprintf_s implementation (which is just like swprintf from GNU guys) by using a define. Your error pretty much tells exactly the problem - your swprintf expects another parameter type. Which means for some reason the define Irrlicht uses is not even compiled and instead the Microsoft version of swprintf is compiled. Which is why I try to figure out now why that could happen in your case.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

that's odd, because I replaced everything, will try again tomorrow.... double checking that everything actually behaves the way I want.... (might be because I was running multiple instances at the same time??)
"this is not the bottleneck you are looking for"
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

replacing all of main.cpp with the second test....

now the errors are in q3factory.cpp

Code: Select all

yes, tried again.....
 
btw all of main.cpp was replaced last time, the errors are in q3factory when doing the second change to main......
 
[code]||=== Irrlicht Example 21 Quake 3 Explorer, Windows ===|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|11|warning: "swprintf" redefined|
..\..\include\irrTypes.h|101|note: this is the location of the previous definition|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::model'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::sound'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::icon'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::pickup'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::value'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::group'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::sub'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|286|warning: missing initializer for member 'SItemElement::special'|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp||In function 'void Q3ShaderFactory(irr::scene::quake3::Q3LevelLoadParameter&, irr::IrrlichtDevice*, irr::scene::IQ3LevelMesh*, irr::scene::quake3::eQ3MeshIndex, irr::scene::ISceneNode*, irr::scene::IMetaTriangleSelector*, bool)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|407|error: 'swprintf_s' was not declared in this scope|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp||In function 'void Q3ModelFactory(irr::scene::quake3::Q3LevelLoadParameter&, irr::IrrlichtDevice*, irr::scene::IQ3LevelMesh*, irr::scene::ISceneNode*, bool)':|
r\Skrivbord\irrlicht-1.7.2\examples\21.Quake3Explorer\q3factory.cpp|644|error: 'swprintf_s' was not declared in this scope|
||=== Build finished: 3 errors, 9 warnings ===|
[/code]
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

Ok, don't care about the second file for now. It would be sufficient just compiling main.cpp for now (if you click the filename with right mouse button you get a "compile" option which only compiles that .cpp).

The fact that you got no compile-error means that _IRR_WINDOWS_API_ is not set - correctly in this case (otherwise the next line would produce an error as it contains just random text instead of c++ code). So next test add the irrlicht include before it, then if everything would be right we should get a compile error:

Code: Select all

 
#include "irrlicht.h"
#ifdef _IRR_WINDOWS_API_
compile error A
#if defined(_MSC_VER) && _MSC_VER > 1310 && !defined (_WIN32_WCE)
compile error B
#endif
#endif
 
edit: if you got an error in the line of "compile error A" then just out-comment or delete that line and check if you then get "compile error B" next.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

now the second example gave an error :D

Except, I can't see how this helps solving the tutorial not compiling...

compile error B wasn't triggered....

Compiling: main.cpp
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
"this is not the bottleneck you are looking for"
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by CuteAlien »

And it still isn't triggered when you removed the line with the first error?

And well - I have to figure out what is going wrong in your case before I can help you. This are all tests to locate the real error. There seems to be some define having different values than on my VS Express here - and I need to figure out which one it is.

edit: Another test - go with your mouse over _MSC_VER, usually VS express should then give you some number. Which one is it in your case?

edit2: Also if you are thinking with me you can probably already guess what the next test is ^_^ (only one define left to check...)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Cube_
Posts: 1010
Joined: Mon Oct 24, 2011 10:03 pm
Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d

Re: error: invalid conversion from 'int' to 'const wchar_t*'

Post by Cube_ »

#define _MSC_VER 1500
"this is not the bottleneck you are looking for"
Post Reply