MFC Conversion to Unicode in VS2008
-
Hi I'm converting an existing C++ MFC project in VS2008 to Unicode. The project had previously been upgraded to VS2008 from VS2005 and is running successfully as MBCS built by VS2008. I have also successfully tested a small (new) MFC Unicode app in C++. I set the Project Properties to "Use Unicode ..." instead of MBCS and did a rebuild. UNICODE and _UNICODE are defined in the Preprocessor directives due to 'Use Unicode ...' in the project properties. When I build I get a lot of errors related to the definition of szFaceName in CHARFORMAT2. The errors are related to the definition of CHARFORMAT szFaceName as 'char' rather than WCHAR. Looking at the definition of CHARFORMAT2 in Richedit.h it has: #ifdef UNICODE #define CHARFORMAT2 CHARFORMAT2W #else #define CHARFORMAT2 CHARFORMAT2A #endif and the CHARFORMAT2A line is the one highlighted - effectively saying that UNICODE is NOT defined. I am at a loss to understand why UNICODE is undefined in Richedit.h and how to fix it. I have tried defining UNICODE and _UNICODE in stdafx.h without any success. I'd be grateful for any help with this - its driving me crackers. Thanks in anticipation :)
-
Hi I'm converting an existing C++ MFC project in VS2008 to Unicode. The project had previously been upgraded to VS2008 from VS2005 and is running successfully as MBCS built by VS2008. I have also successfully tested a small (new) MFC Unicode app in C++. I set the Project Properties to "Use Unicode ..." instead of MBCS and did a rebuild. UNICODE and _UNICODE are defined in the Preprocessor directives due to 'Use Unicode ...' in the project properties. When I build I get a lot of errors related to the definition of szFaceName in CHARFORMAT2. The errors are related to the definition of CHARFORMAT szFaceName as 'char' rather than WCHAR. Looking at the definition of CHARFORMAT2 in Richedit.h it has: #ifdef UNICODE #define CHARFORMAT2 CHARFORMAT2W #else #define CHARFORMAT2 CHARFORMAT2A #endif and the CHARFORMAT2A line is the one highlighted - effectively saying that UNICODE is NOT defined. I am at a loss to understand why UNICODE is undefined in Richedit.h and how to fix it. I have tried defining UNICODE and _UNICODE in stdafx.h without any success. I'd be grateful for any help with this - its driving me crackers. Thanks in anticipation :)
Selumbei wrote:
did a rebuild.
I presume that included deleting and rebuilding your pre-compiled header (.pch) file? That's where the definition of CHARFORMAT2 probably is.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
Selumbei wrote:
did a rebuild.
I presume that included deleting and rebuilding your pre-compiled header (.pch) file? That's where the definition of CHARFORMAT2 probably is.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Hi I made sure that my project .pch file was gone and tried again without success. However there is a second project in the solution (on which my project is dependent). When I made sure the second project's .pch file was deleted it solved the issue. So your suggestion was spot on - thanks :) Now all I have to do is go through and correct all of the 'real' errors caused by previous developers not using the transmutable macros etc :( Thanks again.