Problem with compiling Techdemo with DevCpp

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Tecdemo compiled, no or almost no bugs

Post by Electron »

Dunno, he mostly uses VC++

Okay, heres how I modified the swprintf function to get a formated string for output without invalid conversion errors.

char temp[255];

wsprintf(temp, TEXT("%s fps:%d polys:%d"), driver->getName(),
driver->getFPS(), driver>getPrimitiveCountDrawn());
for (int i=0; i<256;i++)
{
tmp=(wchar_t)temp;
}
for some reason only the first letter of the rendering type seems to come out, but the fps and triangle counts come out fine
alexem
Posts: 35
Joined: Sun Feb 29, 2004 4:55 pm

Post by alexem »

I just deleted the ,255
and it works
but the DirectX is another topic
Yours sencerely,
Alexander Milanoff
NinjaNL
Posts: 19
Joined: Sat Mar 27, 2004 6:53 pm

Post by NinjaNL »

The cause is rather convoluted. The solution is indeed simple.

The cause:

Irrlicht.h redefines swprintf as _snwprintf

#include <wchar.h>
#ifdef _WIN32
//! Define for swprintf because this method does not match the ISO C standard
//! on Win32 platforms, but it does on all other ones.
#define swprintf _snwprintf
#endif // WIN32

CDemo.h then includes <audiere.h>

<audiere.h> includes <string>

<string> includes <iosfwd>

<iosfwd> includes <fpos.h>

<fpos.h> includes <cwchar>

swprintf is undefined in <cwchar>
redefined as
#if _GLIBCPP_USE_WCHAR_T
namespace std
{
using ::swprintf;
}

Thus losing its definition as _snwprintf, reverting back to the original swprintf.

The solution is indeed to use _snwprintf in place of swprintf.
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

thanks, that's interesting
Post Reply