Jump to content

  • Log In with Google      Sign In   
  • Create Account

DXUTTRACE doesn't provide formatted message?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 28 February 2012 - 03:11 AM

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?

Sponsor:

#2 Evil Steve   Members   -  Reputation: 1987

Like
0Likes
Like

Posted 28 February 2012 - 03:38 AM

What number does it show? Does the number change between runs of your application?

Steve Macpherson
Systems Programmer

Rockstar North


#3 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 28 February 2012 - 07:21 PM

it doesn't change. It's 1242160 all the time.

#4 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 01 March 2012 - 06:20 AM

Did anybody come across the same problem?

#5 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 02 March 2012 - 02:33 AM

The console maybe joke with me.Posted Image

#6 Martins Mozeiko   Crossbones+   -  Reputation: 1422

Like
0Likes
Like

Posted 02 March 2012 - 06:55 AM

How can it compile, if first argument is LPCWSTR, but you are passing LPCSTR ?

#7 Evil Steve   Members   -  Reputation: 1987

Like
0Likes
Like

Posted 02 March 2012 - 09:36 AM

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.

Steve Macpherson
Systems Programmer

Rockstar North


#8 Jeason   Members   -  Reputation: 96

Like
0Likes
Like

Posted 06 March 2012 - 08:46 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS