Jump to content
  • Advertisement
Sign in to follow this  
xujiezhige

DXUTTRACE doesn't provide formatted message?

This topic is 2475 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.


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?

Share this post


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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!