Skip to main content
gamedev.net
🔒 Locked

Remove TEXT Warning

Started by The Lion King May 24, 2002 at 11:28 AM 2 replies 350+ views
Original Post
The Lion King
The Lion King
Hi, Take a look at the following piece of code: int Length; TCHAR szBuffer[40]; // Warning point strcpy(szBuffer, TEXT("Line : %d X : %d Y : %d", i, x, y)); Length = wsprintf(szBuffer, TEXT("Line : %d, X : %d, Y : %d"),i, x, y); TextOut(hDc, x, y, szBuffer, Length); The code works fine but gives a WARNING Message as under: E:\My Documents\My Projects\Writing Text\Messages.cpp(101) : warning C4002: too many actual parameters for macro ''TEXT'' I am using Visual C++ 6. The program works fine, but warnings can create a lot of trouble in some cases. There is something to do with TEXT. Even if I initialize szBuffer like: TCHAR szBuffer[40] = TEXT("Line : %d, X : %d, Y : %d", i, x, y); Then it gives warning here. How do I remove this warning Message? What is wrong with it? What are the actual parameters of TEXT? Anny suggestions... Thanks, I can survive anything ... even NUKES!!! The Lion King
cgoat
cgoat
You don''t seem to need that strcpy line at all. The wsprintf does exactly what it seems you want the strcpy to do.

TEXT() only takes one parameter, you''re passing it 4, so it''s ignoring the remaining 3.
LessBread
LessBread
quote:
Original post by The Lion King
strcpy(szBuffer, TEXT("Line : %d X : %d Y : %d", i, x, y));


You've put too much into the TEXT macro - and that's not how to use strcpy. Try this instead:

wsprintf(szBuffer,
TEXT("Line : %d X : %d Y : %d"),
i, x, y);

quote:
Original post by The Lion King
What are the actual parameters of TEXT?



TEXT is a macro that prepends an "L" to the string when UNICODE is defined - thus making the string UNICODE. It does nothing when UNICODE is not defined

#ifdef UNICODE
#define TEXT(quote) L##quote
#else
#define TEXT(quote) quote
#endif


[edited by - lessbread on May 24, 2002 12:39:08 PM]
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
The Lion King
The Lion King
I know that TEXT takes one parameter. But, value returned by wsprintf() is integer.

I have to use

"Line : %d, X : %d, Y : %d",i, x, y

to be displayed on the Window at various place.

Its value must be stored in a string.

Any suggestions?

or any other way to accomplish this task?

P.S. Its not an error. It''s a waning message. My application does what it needs to do, but I don''t want that warning message

Please help!!!



I can survive anything ... even NUKES!!!

The Lion King

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.