UNICODE in Console

Code 2012. 8. 19. 21:14

UNICODE in Console

//===========================================================================
//에러!
ANSI콘솔 프로젝트를 유니코드로 바꾸기 위해 Link 설정에 /entry:"wWinMainCRTStartup" 을 추가하면
아래와 같은 에러가 발생한다.
LIBCD.lib(wwincrt0.obj) : error LNK2001: unresolved external symbol _wWinMain@16


//===========================================================================

* Win32 Console 프로그램에서 유니코드 사용하기

    - Project -> Settings -> C/C++ 탭
        _MBSC 를 _UNICODE로 교체
    - Project -> Settings -> Link 탭
        /entry:"wmainCRTStartup" 추가

- 일반 윈도우 프로젝트에서는 /entry:"wWinMainCRTStartup"

    - 메인함수 교체
        int main( int argc, char *argv[ ], char *envp[ ] )
        -> int wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )

//===========================================================================
참조 : http://www.flipcode.com/archives/Win32_ConsoleWindowed_Tip.shtml
#ifndef __WIN32CONSOLE_INCLUDED
#define __WIN32CONSOLE_INCLUDED

   /****************************************************************

   compile with -DWIN32CONSOLE=1 to have console

   and          -DWIN32CONSOLE=0 to hide console          -- default

   compile with -DWIN32WINMAIN=1 to start from WinMain()
   and          -DWIN32WINMAIN=0 to start from main()     -- default

   by: malkia/eastern.analog malkia@mindless.com malkia@digitald.com
   url: http://EasternAnalog.hypermart.net url: www.digitald.com

   Have effect only with MSVC 5.0+ when target platform is WIN32 and
   <windows.h being included. I didn't test it on other compilers..

   ****************************************************************/

   #if defined(_MSC_VER) && defined(_WIN32)
       #if WIN32WINMAIN
           #if _UNICODE
               #pragma comment(linker,"/ENTRY:wWinMainCRTStartup")
           #else
               #pragma comment(linker,"/ENTRY:WinMainCRTStartup")
           #endif
       #else
           #if _UNICODE
               #pragma comment(linker,"/ENTRY:wmainCRTStartup")
           #else
               #pragma comment(linker,"/ENTRY:mainCRTStartup")
           #endif
       #endif

       #if WIN32CONSOLE

           #pragma comment(linker,"/SUBSYSTEM:CONSOLE")
       #else

           #pragma comment(linker,"/SUBSYSTEM:WINDOWS")

       #endif
   #endif /* _MSC_VER, _WIN32 */

#endif /* __WIN32CONSOLE_INCLUDED__ */

//===========================================================================

반응형

'Code' 카테고리의 다른 글

Time  (0) 2012.08.19
OEP 찾는 방법들  (0) 2012.08.19
RTTI  (0) 2012.08.19
pragma 정리  (0) 2012.08.19
Pointer Test  (0) 2012.08.19
Posted by codens