DXUTTRACE doesn't provide formatted message?

Started by
6 comments, last by xujiezhige 12 years, 1 month ago
I type the following scentence, but it doesn't show 100, but a random number.


DXUTTRACE( "NumFace: %d\n", 100 );


I find some information.

#define DXUTTRACE DXUTOutputDebugString
#define DXUTOutputDebugString DXUTOutputDebugStringW

VOID WINAPI DXUTOutputDebugStringW( LPCWSTR strMsg, ... )
{
#if defined(DEBUG) || defined(_DEBUG)
WCHAR strBuffer[512];
va_list args;
va_start(args, strMsg);
swprintf_s( strBuffer, 512, strMsg, args );
strBuffer[511] = L'\0';
va_end(args);
OutputDebugString( strBuffer );
#else
UNREFERENCED_PARAMETER( strMsg );
#endif
}



So the function could format message, why do it give wrong result?
Advertisement
What number does it show? Does the number change between runs of your application?
it doesn't change. It's 1242160 all the time.
Did anybody come across the same problem?
The console maybe joke with me.mellow.png
How can it compile, if first argument is LPCWSTR, but you are passing LPCSTR ?
Does it work correctly if you call DXUTTRACE at the start of your application? If so, at what point does it go wrong? It's possible that there's stack corruption or similar.
Yes, I think stack corruption exists. the address of args is wrong after va_start().
I can't solve it now.

I have tried a almost empty projection, and invoked DXUTTRACT at the first line in WinMain. But the error is the same as before.
All samples in DXSDK take the same phenomenon.

This topic is closed to new replies.

Advertisement