• Advertisement
Sign in to follow this  

DXUTTRACE doesn't provide formatted message?

This topic is 2144 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I type the following scentence, but it doesn't show 100, but a random number.

[CODE]
DXUTTRACE( "NumFace: %d\n", 100 );
[/CODE]

I find some information.
[CODE]
#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
}

[/CODE]

So the function could format message, why do it give wrong result?

Share this post


Link to post
Share on other sites
Advertisement
The console maybe joke with me.[img]http://public.gamedev.net//public/style_emoticons/default/mellow.png[/img]

Share this post


Link to post
Share on other sites
How can it compile, if first argument is LPCWSTR, but you are passing LPCSTR ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement