Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCHAR*

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
Function(TCHAR *szRet)

I'm trying to use the above example function by doing:

TCHAR buf [1024];
Function(&buf[0]);

I get this compilation error:

cannot convert parameter 1 from 'char *' to 'unsigned short *'

Any ideas?
 
Your syntax is wrong.

Change Function(&buf[0]) to Function(buf)

Temps
 
If I do that I get:

Cannot convert parameter 1 from 'char [1024]' to 'unsigned short *'
 
Do you have UNICODE defined? And if so, did you do it in the file or in the project settings?

Your function

Function(TCHAR* szRet);

should have NO problem with the call

Function(&buf[0]);
or
Function(buf);

One more question, do you link to multiple projects?

Matt

 
UNICODE isn't defined. Should this matter?
 
Yes. For some reason, in one spot it sounds like UNICODE is defined. There exists a precomplier directive as follows

#ifdef _UNICODE
typedef TCHAR char;
#else
typedef TCHAR wchar_t;
#endif

put a #undef _UNICODE before your function and see if you can get it to compile. This should NOT be left in but it will let you know if _UNICODE has been defined in your project.

Matt
 
Actually, thinking about it, most likely you are using "precompiled headers" and the #undef MAY not work.

Go into project settings for all your projects, click on the C++ tab and select "Preprocessor" from the dropdown list. Make sure _UNICODE is not in the list of "Preprocessor Definitions"

I have never used it but "Undefined Symbols" could get _UNICODE added and have the same effect I THINK

Matt
 
You got me on the right lines with the UNICODE- it turns out the function I'm calling takes a WCHAR, not a TCHAR. I'm now going to go slap my colleague who wrote this function :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top