-
August 27th, 2001, 01:03 PM
#1
Errors on release build with UNICODE
Can someone explain to me why I would need to include UNICODE in my application? I seem to be having some problems when I switch from debug to release build. If I comment out all my stuff in my stdafx.h file that deals with unicode,
#define _WIN32_WINNT 0x403
//#define UNICODE
#define _UNICODE
#include <windows.h>
#include <iostream>
using namespace std;
#ifdef UNICODE
#define _tcout wcout
#define _tostream wostream
#else
#define _tcout cout
#define _tostream ostream
#endif
it builds fine but gives me an error when I try to run the program (Application Error the memory could not be written...). If I leave the UNICODE stuff in, when It builds I get the error
Compiling...
CVIEWService.cpp
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxinet.inl(39) : error C2664: 'GopherGetLocatorTypeW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'. It is a problem between my debug and release builds, because the debug build works great! I have checked the project settings and there is no unicode defined in the release build. Does anyone have any suggestions????
-
August 27th, 2001, 03:10 PM
#2
Re: Errors on release build with UNICODE
try putting _UNICODE in your preprocessor directives in Project|Setttings|C++|Preprocessor...
CodeHacker
Rate me if it helped, Thanks
-
August 27th, 2001, 03:19 PM
#3
Re: Errors on release build with UNICODE
I have tried that. It gives me a ton of other errors. I think the problem that I have comes from the fact that I took existing C code and added it to my MFC project. I think that the old code uses UNICODE stuff (atleast the header file includes UNICODE), and obviously the MFC stuff does not. How can I get around this?
-
August 27th, 2001, 03:47 PM
#4
Re: Errors on release build with UNICODE
Did you remember to put wWinMainCRTStartup as your Link|Entry Point?
CodeHacker
Rate me if it helped, Thanks
-
August 27th, 2001, 03:54 PM
#5
Re: Errors on release build with UNICODE
Okay, you lost me. How do I do that? Where is my link/entry point? and how do I put wWinMainCRTStartup there or check to see if it is there. I assume that it is under project/settings, but the only thing that I see there that has to do with link and entry is under the link tab and the output option.
-
August 27th, 2001, 04:01 PM
#6
Re: Errors on release build with UNICODE
That's exactly where you put it 8-)
CodeHacker
Rate me if it helped, Thanks
-
August 27th, 2001, 04:06 PM
#7
Re: Errors on release build with UNICODE
When I put it there it gives me a linking error if I do not include the unicode in the header. If I do include the Unicode, (#define UNICODE) then it gives me the same 3 original errors.
--------------------Configuration: CVIEW Service - Win32 Release--------------------
Compiling...
CVIEWService.cpp
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxinet.inl(39) : error C2664: 'GopherGetLocatorTypeW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Service.cpp
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxinet.inl(39) : error C2664: 'GopherGetLocatorTypeW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
xCVIEW.cpp
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxinet.inl(39) : error C2664: 'GopherGetLocatorTypeW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Generating Code...
Error executing cl.exe.
CVIEWService.exe - 3 error(s), 0 warning(s)
-
August 27th, 2001, 04:07 PM
#8
Re: Errors on release build with UNICODE
I'm assuming these errors are on lines containing literal strings. Just put an L in front of your string, like...
L"Hello World"
CodeHacker
Rate me if it helped, Thanks
-
August 27th, 2001, 04:12 PM
#9
Re: Errors on release build with UNICODE
Actually the errors are coming from a Microsoft file not from my code. My project seems to have a problem with the Microsoft code in "afxinet.inl". If it was just as easy as putting an L in front of a string, I would jump for joy. I think this problem is a little more complex. I have been stuck on it for days. Thanks for all the advice though. I will go though and rate what we have discussed. Please let me know if you have any other ideas. I am at the end of my rope.
-
August 27th, 2001, 04:19 PM
#10
Re: Errors on release build with UNICODE
Your problem is that _UNICODE is not being defined early enough. The error results because the LPCTSTR type is being defined as const char * instead of const unsigned short * (wchar_t). Do you define _UNICODE before any includes in stdafx.h?
Chris Richardson
-
August 27th, 2001, 04:22 PM
#11
Re: Errors on release build with UNICODE
I had a funky problem with UNICODE once and it turned out that I HAD to have #include "stdafx.h" as the 1st include in ALL of my files. Also, check your precompiled header settings for all of your files. Other than that good luck. Thanks for rating.
CodeHacker
Rate me if it helped, Thanks
-
August 27th, 2001, 04:25 PM
#12
Re: Errors on release build with UNICODE
Make sure the preprocessor definition MCBS is not in your settings as well! That bit me once. If none of this works I would manually go through ALL of the project settings in the debug mode since it works. Then compare them to your release settings. Only things like _DEBUG, etc should be different.
CodeHacker
Rate me if it helped, Thanks
-
August 27th, 2001, 04:26 PM
#13
Re: Errors on release build with UNICODE
Great suggestion. I have messed around with it and put my #define UNICODE at the very top of my stdafx.h file and I get 102 errors all of them similar in syntax.
Compiling...
StdAfx.cpp
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ios.h(146) : error C2872: 'streambuf' : ambiguous symbol
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ios.h(159) : error C2872: 'ostream' : ambiguous symbol
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ios.h(159) : error C2872: 'ostream' : ambiguous symbol
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ios.h(160) : error C2872: 'ostream' : ambiguous symbol
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ios.h(180) : error C2872: 'streambuf' : ambiguous symbol
etc ...
I have even commented out everything except the MFC stuff and the unicode stuff.
//#define _WIN32_WINNT 0x403
#define UNICODE
#define _UNICODE
//#include <windows.h>
//#include <iostream>
//using namespace std;
#ifdef UNICODE
#define _tcout wcout
#define _tostream wostream
#else
#define _tcout cout
#define _tostream ostream
#endif
#include <TCHAR.H>
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <iostream.h>
#include <process.h>
#include <TCHAR.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#include <afxmt.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
and then I get the following errors,
Compiling...
StdAfx.cpp
Compiling...
common.cpp
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(68) : error C2664: 'CreateProcessW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(114) : error C2664: 'CreateProcessW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(176) : error C2664: 'RegEnumKeyW' : cannot convert parameter 3 from 'char [260]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(181) : error C2664: 'RegEnumKeyW' : cannot convert parameter 3 from 'char [260]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(184) : error C2664: 'RegOpenKeyExW' : cannot convert parameter 2 from 'char [260]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(254) : error C2664: 'RegEnumKeyW' : cannot convert parameter 3 from 'char [260]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(259) : error C2664: 'RegEnumKeyW' : cannot convert parameter 3 from 'char [260]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\common.cpp(262) : error C2664: 'RegOpenKeyExW' : cannot convert parameter 2 from 'char [260]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
CVIEWService.cpp
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\CVIEWService.cpp(373) : error C2664: '__thiscall CEventLog::CEventLog(const unsigned short *,const unsigned short *)' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\CVIEWService.cpp(403) : error C2664: 'CreateMutexW' : cannot convert parameter 3 from 'char [17]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\CVIEWService.cpp(477) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [257]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\CVIEWService.cpp(478) : error C2664: 'strcpy' : cannot convert parameter 1 from 'unsigned short [257]' to 'char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
EventLog.cpp
Service.cpp
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\Service.cpp(294) : error C2664: 'CxCVIEW::CxCVIEW' : cannot convert parameter 1 from 'char [7]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
E:\CLC\VSS\xCVIEW\xCVIEW code modifications\Service.cpp(370) : error C2664: '__thiscall CEventLog::CEventLog(const unsigned short *,const unsigned short *)' : cannot convert parameter 1 from 'char [7]' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
xCVIEW.cpp
.
.
.
etc (72 of those)
-
August 27th, 2001, 04:42 PM
#14
Re: Errors on release build with UNICODE
I hope that was not a sarcastic 'Great Suggestion' in your last post. If you knew what was going on with those errors, you would simply go fix them. Replace all your instances of char with TCHAR, and you will get rid of some of them. The next step is to replace your function calls like strcpy with the TCHAR equivalents. In the case of strcpy it is _tcscpy. The last step is when you have literal strings, you should put eclose them in the _T macro like this:
const TCHAR * pString = _T("Hello");
I have just done this to a large application and it is not very difficult. Then it will build unicode and ansi, debug and release.
Chris Richardson
-
August 28th, 2001, 08:22 AM
#15
Re: Errors on release build with UNICODE
Did you resolve this issue? If so, please post the solution for the rest of us.
CodeHacker
Rate me if it helped, Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|