?
Solved

turning off unicode for a particular block

Posted on 2006-04-26
2
Medium Priority
?
243 Views
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),
                                                        m_szFlexLMVersion.GetBuffer(0),
                                                        &m_lFlexLMHandle,
                                                        &nLicenses);
                #undef  _MBCS
                #define _UNICODE
      
#endif

///////////////////////////////////////////////////////////////////////
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);
0
Comment
Question by:Joe_Banks_217
2 Comments
 
LVL 86

Accepted Solution

by:
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.

USES_CONVERSION;

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

                iStatus = FUNCTION_CALL( szFlexLMFeature,
                                                        szFlexLMVersion,
                                                        &m_lFlexLMHandle,
                                                        &nLicenses);

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

Author Comment

by:Joe_Banks_217
ID: 16546883
Great, thank you jkr
0

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