turning off unicode for a particular block

Posted on 2006-04-26
Medium Priority
Last Modified: 2010-04-01
hi all,
  i have a particular block of code that i never want to be unicode. right now i have:

#ifdef _UNICODE

                #undef  _UNICODE
                #define _MBCS

                iStatus = FUNCTION_CALL( m_szFlexLMFeature.GetBuffer(0),
                #undef  _MBCS
                #define _UNICODE

However, this doesn't seem to work. i still get the build error:

error C2664: 'FUNCTION_CALL' : cannot convert parameter 1 from 'unsigned short *' to 'char []'

FUNCTION_CALL is implemented in an external library; all i do is put this prototype in the .h:

extern "C" long WINAPI FUNCTION_CALL( char LMFEATURE[3], char LMVERSION[4], long* LMHANDLE, long* NTOKENS);
Question by:Joe_Banks_217
LVL 86

Accepted Solution

jkr earned 1000 total points
ID: 16546538
>>FUNCTION_CALL is implemented in an external library; all i do is put this prototype in the .h

That #undef part won't affect the CString arguments, they're UNICODE anyway. Better convert the arguments to ANSI when you need them, e.g.


char* szFlexLMFeature = W2A(m_szFlexLMFeature.GetBuffer(0));
char* szFlexLMVersion = W2A(m_szFlexLMVersion.GetBuffer(0));

                iStatus = FUNCTION_CALL( szFlexLMFeature,

See also http://msdn.microsoft.com/library/en-us/vclib/html/_mfcnotes_tn059.asp ("TN059: Using MFC MBCS/Unicode Conversion Macros")

Author Comment

ID: 16546883
Great, thank you jkr

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question