Skip to main content
GameDev.net gamedev.net
🔒 Locked

Making MBCS and UNICODE live together

Started by moeron Oct 11, 2006 at 11:42 AM 2 replies 1.3k views
Original Post
moeron
moeron
I have a situation where an SDK I need to use defines its character type as a TCHAR. Sounds great right? Well the problem is that they define their character as a TCHAR but then never use anything other than MBCS functions and they never use the _T() macro around any of their string literals. So now that I need to make my plugin Unicode - I have a million problems with the header files I need to include. So this prompts my question - has anyone out there ever had a situation like this? I'm thinking I need to make some kind of a wrapper header file to fool my SDK includes into thinking that MBCS is defined - but so far I'm having no luck. I don't know if I need to undefine some things or if #pragma once is preventing me from including tchar.h or other headers twice. Has anyone been down this road before?
moe.ron
NotAYakk
NotAYakk
Write a SDK wrapper that isn't idiotic?
Colin Jeanne
Colin Jeanne
Maybe include your SDK headers like so:

#ifdef UNICODE#undef UNICODE#endif#ifdef _UNICODE#undef _UNICODE#endif#include "sdkheader.h"#define UNICODE#define _UNICODE


This assumes that you arent also compiling the source files. If you have the source files you could also go and make the changes yourself.
moeron
moeron
Quote:
Original post by NotAYakk
Write a SDK wrapper that isn't idiotic?

Thanks for the insight


Quote:
Original post by Colin Jeanne
// source snipped
This assumes that you arent also compiling the source files. If you have the source files you could also go and make the changes yourself.

I don't have the source files - just header files and the libraries.

Your suggestion was basically what I started out attempting to do. But because of #pragma once I couldn't include certain system headers a second time- thus things like _tcslen would still be defined as wcslen even though I undef'd UNICODE and _UNICODE, defined _MBCS and MBCS, undef'd the include guards for the system headers, and then included them again.

In the end I just modified the SDK's header file to just typedef a char instead of a TCHAR since I knew the SDK's library was compiled under MBCS. I was just hoping there was a cleaner solution, or at least a solution that didn't involve me messing with other people's headers.
moe.ron

Topic Locked

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

Sign in to reply to this topic.