From 53b3b979fe73eb75799a6e3e3eb603d62a491846 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 27 Oct 2022 19:15:16 +0200 Subject: [PATCH] Remove tests for _UNICODE too It is now always defined, so testing for it is useless. Give an error in MSVC-specific header if it is not defined as it should be. --- docs/msw/install.md | 1 - include/msvc/wx/setup.h | 29 +++----- include/wx/msw/htmlhelp.h | 21 ------ include/wx/msw/winundef.h | 148 ++++++-------------------------------- samples/mfc/mfctest.cpp | 2 - src/msw/ole/activex.cpp | 4 -- src/msw/ole/uuid.cpp | 24 ------- src/msw/version.rc | 9 +-- 8 files changed, 31 insertions(+), 207 deletions(-) diff --git a/docs/msw/install.md b/docs/msw/install.md index 0d722e77cd..98b5393428 100644 --- a/docs/msw/install.md +++ b/docs/msw/install.md @@ -465,7 +465,6 @@ Here is what you need to do: be used for debug builds only. * Define the following symbols for the preprocessor: - `__WXMSW__` to ensure you use the correct wxWidgets port. - - `_UNICODE` unless you want to use deprecated ANSI build of wxWidgets. - `NDEBUG` if you want to build in release mode, i.e. disable asserts. - `WXUSINGDLL` if you are using DLL build of wxWidgets. * Add `` directory described above to the libraries path. diff --git a/include/msvc/wx/setup.h b/include/msvc/wx/setup.h index 8958328f1f..6f64a2bf66 100644 --- a/include/msvc/wx/setup.h +++ b/include/msvc/wx/setup.h @@ -19,24 +19,19 @@ #include "wx/version.h" #include "wx/cpp.h" +#ifndef _UNICODE + #error "wxWidgets requires Unicode." +#endif + // notice that wxSUFFIX_DEBUG is a string but wxSUFFIX itself must be an // identifier as string concatenation is not done inside #include where we // need it #ifdef _DEBUG #define wxSUFFIX_DEBUG "d" - #ifdef _UNICODE - #define wxSUFFIX ud - #else // !_UNICODE - #define wxSUFFIX d - #endif // _UNICODE/!_UNICODE + #define wxSUFFIX ud #else #define wxSUFFIX_DEBUG "" - #ifdef _UNICODE - #define wxSUFFIX u - #else // !_UNICODE - // don't define wxSUFFIX at all as preprocessor operations don't work - // with empty values so we need to check for this case specially below - #endif // _UNICODE/!_UNICODE + #define wxSUFFIX u #endif // compiler-specific prefix: by default it's always just "vc" for compatibility @@ -115,11 +110,7 @@ #endif #endif // wxTOOLKIT_PREFIX -#ifdef wxSUFFIX - #define wxTOOLKIT_FULL wxCONCAT(wxTOOLKIT_PREFIX, wxSUFFIX) -#else // suffix is empty - #define wxTOOLKIT_FULL wxTOOLKIT_PREFIX -#endif +#define wxTOOLKIT_FULL wxCONCAT(wxTOOLKIT_PREFIX, wxSUFFIX) // the real setup.h header file we need is in the build-specific directory, // construct the path to it @@ -132,11 +123,7 @@ // the library names depend on the build, these macro builds the correct // library name for the given base name -#ifdef wxSUFFIX - #define wxSUFFIX_STR wxSTRINGIZE(wxSUFFIX) -#else // suffix is empty - #define wxSUFFIX_STR "" -#endif +#define wxSUFFIX_STR wxSTRINGIZE(wxSUFFIX) #define wxSHORT_VERSION_STRING \ wxSTRINGIZE(wxMAJOR_VERSION) wxSTRINGIZE(wxMINOR_VERSION) diff --git a/include/wx/msw/htmlhelp.h b/include/wx/msw/htmlhelp.h index 3e8a7caf92..e727ba4815 100644 --- a/include/wx/msw/htmlhelp.h +++ b/include/wx/msw/htmlhelp.h @@ -178,11 +178,7 @@ typedef struct tagHH_POPUPW { LPCWSTR pszFont; } HH_POPUPW; -#ifdef _UNICODE typedef HH_POPUPW HH_POPUP; -#else -typedef HH_POPUPA HH_POPUP; -#endif typedef struct tagHH_ALINKA { int cbStruct; @@ -206,13 +202,8 @@ typedef struct tagHH_ALINKW { BOOL fIndexOnFail; } HH_ALINKW; -#ifdef _UNICODE typedef HH_ALINKW HH_ALINK; typedef HH_ALINKW HH_AKLINK; -#else -typedef HH_ALINKA HH_ALINK; -typedef HH_ALINKA HH_AKLINK; -#endif enum { HHWIN_NAVTYPE_TOC, @@ -296,11 +287,7 @@ typedef struct tagHH_FTS_QUERYW { LPCWSTR pszWindow; } HH_FTS_QUERYW; -#ifdef _UNICODE typedef HH_FTS_QUERYW HH_FTS_QUERY; -#else -typedef HH_FTS_QUERYA HH_FTS_QUERY; -#endif typedef struct tagHH_WINTYPEA { int cbStruct; @@ -380,11 +367,7 @@ typedef struct tagHH_WINTYPEW { LPCWSTR pszCustomTabs; } HH_WINTYPEW, *PHH_WINTYPEW; -#ifdef _UNICODE typedef HH_WINTYPEW HH_WINTYPE; -#else -typedef HH_WINTYPEA HH_WINTYPE; -#endif enum { HHACT_TAB_CONTENTS, @@ -427,11 +410,7 @@ typedef struct tagHH_NTRACKW { PHH_WINTYPEW phhWinType; } HH_NTRACKW; -#ifdef _UNICODE typedef HH_NTRACKW HH_NTRACK; -#else -typedef HH_NTRACKA HH_NTRACK; -#endif HWND WINAPI HtmlHelpA(HWND,LPCSTR,UINT,DWORD); HWND WINAPI HtmlHelpA(HWND,LPCSTR,UINT,DWORD); diff --git a/include/wx/msw/winundef.h b/include/wx/msw/winundef.h index feebf2b6eb..f059e6049a 100644 --- a/include/wx/msw/winundef.h +++ b/include/wx/msw/winundef.h @@ -15,14 +15,6 @@ #define _WX_WINUNDEF_H_ */ -#ifndef wxUSE_UNICODE_WINDOWS_H - #ifdef _UNICODE - #define wxUSE_UNICODE_WINDOWS_H 1 - #else - #define wxUSE_UNICODE_WINDOWS_H 0 - #endif -#endif - // ---------------------------------------------------------------------------- // windows.h #defines the following identifiers which are also used in wxWin so // we replace these symbols with the corresponding inline functions and @@ -42,11 +34,7 @@ HWND hwndParent, DLGPROC pDlgProc) { - #if wxUSE_UNICODE_WINDOWS_H - return CreateDialogW(hInstance, pTemplate, hwndParent, pDlgProc); - #else - return CreateDialogA(hInstance, pTemplate, hwndParent, pDlgProc); - #endif + return CreateDialogW(hInstance, pTemplate, hwndParent, pDlgProc); } #endif @@ -70,17 +58,10 @@ DWORD family, LPCTSTR facename) { - #if wxUSE_UNICODE_WINDOWS_H - return CreateFontW(height, width, escapement, orientation, - weight, italic, underline, strikeout, charset, - outprecision, clipprecision, quality, - family, facename); - #else - return CreateFontA(height, width, escapement, orientation, - weight, italic, underline, strikeout, charset, - outprecision, clipprecision, quality, - family, facename); - #endif + return CreateFontW(height, width, escapement, orientation, + weight, italic, underline, strikeout, charset, + outprecision, clipprecision, quality, + family, facename); } #endif // CreateFont @@ -98,13 +79,8 @@ HINSTANCE hInstance, LPVOID lpParam) { - #if wxUSE_UNICODE_WINDOWS_H - return CreateWindowW(lpClassName, lpWndClass, dwStyle, x, y, w, h, - hWndParent, hMenu, hInstance, lpParam); - #else - return CreateWindowA(lpClassName, lpWndClass, dwStyle, x, y, w, h, - hWndParent, hMenu, hInstance, lpParam); - #endif + return CreateWindowW(lpClassName, lpWndClass, dwStyle, x, y, w, h, + hWndParent, hMenu, hInstance, lpParam); } #endif @@ -115,11 +91,7 @@ inline HMENU LoadMenu(HINSTANCE instance, LPCTSTR name) { - #if wxUSE_UNICODE_WINDOWS_H - return LoadMenuW(instance, name); - #else - return LoadMenuA(instance, name); - #endif + return LoadMenuW(instance, name); } #endif @@ -130,11 +102,7 @@ inline HWND APIENTRY FindText(LPFINDREPLACE lpfindreplace) { - #if wxUSE_UNICODE_WINDOWS_H - return FindTextW(lpfindreplace); - #else - return FindTextA(lpfindreplace); - #endif + return FindTextW(lpfindreplace); } #endif @@ -142,13 +110,10 @@ #ifdef GetCharWidth #undef GetCharWidth - inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) + + inline BOOL GetCharWidth(HDC dc, UINT first, UINT last, LPINT buffer) { - #if wxUSE_UNICODE_WINDOWS_H return GetCharWidthW(dc, first, last, buffer); - #else - return GetCharWidthA(dc, first, last, buffer); - #endif } #endif @@ -156,102 +121,66 @@ #ifdef FindWindow #undef FindWindow - #if wxUSE_UNICODE_WINDOWS_H + inline HWND FindWindow(LPCWSTR classname, LPCWSTR windowname) { return FindWindowW(classname, windowname); } - #else - inline HWND FindWindow(LPCSTR classname, LPCSTR windowname) - { - return FindWindowA(classname, windowname); - } - #endif #endif // PlaySound #ifdef PlaySound #undef PlaySound - #if wxUSE_UNICODE_WINDOWS_H + inline BOOL PlaySound(LPCWSTR pszSound, HMODULE hMod, DWORD fdwSound) { return PlaySoundW(pszSound, hMod, fdwSound); } - #else - inline BOOL PlaySound(LPCSTR pszSound, HMODULE hMod, DWORD fdwSound) - { - return PlaySoundA(pszSound, hMod, fdwSound); - } - #endif #endif // GetClassName #ifdef GetClassName #undef GetClassName - #if wxUSE_UNICODE_WINDOWS_H + inline int GetClassName(HWND h, LPWSTR classname, int maxcount) { return GetClassNameW(h, classname, maxcount); } - #else - inline int GetClassName(HWND h, LPSTR classname, int maxcount) - { - return GetClassNameA(h, classname, maxcount); - } - #endif #endif // GetClassInfo #ifdef GetClassInfo #undef GetClassInfo - #if wxUSE_UNICODE_WINDOWS_H + inline BOOL GetClassInfo(HINSTANCE h, LPCWSTR name, LPWNDCLASSW winclass) { return GetClassInfoW(h, name, winclass); } - #else - inline BOOL GetClassInfo(HINSTANCE h, LPCSTR name, LPWNDCLASSA winclass) - { - return GetClassInfoA(h, name, winclass); - } - #endif #endif // LoadAccelerators #ifdef LoadAccelerators #undef LoadAccelerators - #if wxUSE_UNICODE_WINDOWS_H + inline HACCEL LoadAccelerators(HINSTANCE h, LPCWSTR name) { return LoadAcceleratorsW(h, name); } - #else - inline HACCEL LoadAccelerators(HINSTANCE h, LPCSTR name) - { - return LoadAcceleratorsA(h, name); - } - #endif #endif // DrawText #ifdef DrawText #undef DrawText - #if wxUSE_UNICODE_WINDOWS_H + inline int DrawText(HDC h, LPCWSTR str, int count, LPRECT rect, UINT format) { return DrawTextW(h, str, count, rect, format); } - #else - inline int DrawText(HDC h, LPCSTR str, int count, LPRECT rect, UINT format) - { - return DrawTextA(h, str, count, rect, format); - } - #endif #endif @@ -260,17 +189,10 @@ #ifdef StartDoc #undef StartDoc - #if wxUSE_UNICODE_WINDOWS_H inline int StartDoc(HDC h, CONST DOCINFOW* info) { return StartDocW(h, const_cast(info)); } - #else - inline int StartDoc(HDC h, CONST DOCINFOA* info) - { - return StartDocA(h, const_cast(info)); - } - #endif #endif // GetObject @@ -279,11 +201,7 @@ #undef GetObject inline int GetObject(HGDIOBJ h, int i, LPVOID buffer) { - #if wxUSE_UNICODE_WINDOWS_H return GetObjectW(h, i, buffer); - #else - return GetObjectA(h, i, buffer); - #endif } #endif @@ -293,11 +211,7 @@ #undef GetMessage inline int GetMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) { - #if wxUSE_UNICODE_WINDOWS_H return GetMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); - #else - return GetMessageA(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax); - #endif } #endif @@ -306,11 +220,7 @@ #undef LoadIcon inline HICON LoadIcon(HINSTANCE hInstance, LPCTSTR lpIconName) { - #if wxUSE_UNICODE_WINDOWS_H - return LoadIconW(hInstance, lpIconName); - #else // ANSI - return LoadIconA(hInstance, lpIconName); - #endif // Unicode/ANSI + return LoadIconW(hInstance, lpIconName); } #endif // LoadIcon @@ -319,11 +229,7 @@ #undef LoadBitmap inline HBITMAP LoadBitmap(HINSTANCE hInstance, LPCTSTR lpBitmapName) { - #if wxUSE_UNICODE_WINDOWS_H - return LoadBitmapW(hInstance, lpBitmapName); - #else // ANSI - return LoadBitmapA(hInstance, lpBitmapName); - #endif // Unicode/ANSI + return LoadBitmapW(hInstance, lpBitmapName); } #endif // LoadBitmap @@ -331,33 +237,21 @@ #ifdef LoadLibrary #undef LoadLibrary - #if wxUSE_UNICODE_WINDOWS_H + inline HINSTANCE LoadLibrary(LPCWSTR lpLibFileName) { return LoadLibraryW(lpLibFileName); } - #else - inline HINSTANCE LoadLibrary(LPCSTR lpLibFileName) - { - return LoadLibraryA(lpLibFileName); - } - #endif #endif // FindResource #ifdef FindResource #undef FindResource - #if wxUSE_UNICODE_WINDOWS_H + inline HRSRC FindResource(HMODULE hModule, LPCWSTR lpName, LPCWSTR lpType) { return FindResourceW(hModule, lpName, lpType); } - #else - inline HRSRC FindResource(HMODULE hModule, LPCSTR lpName, LPCSTR lpType) - { - return FindResourceA(hModule, lpName, lpType); - } - #endif #endif // IsMaximized diff --git a/samples/mfc/mfctest.cpp b/samples/mfc/mfctest.cpp index f9163a03ff..c46d7e9ec6 100644 --- a/samples/mfc/mfctest.cpp +++ b/samples/mfc/mfctest.cpp @@ -159,7 +159,6 @@ wxDECLARE_APP(MyApp); // Notice use of wxIMPLEMENT_APP_NO_MAIN() instead of the usual wxIMPLEMENT_APP! wxIMPLEMENT_APP_NO_MAIN(MyApp); -#ifdef _UNICODE // In Unicode build MFC normally requires to manually change the entry point to // wWinMainCRTStartup() but to avoid having to modify the project options to do // it we provide an adapter for it. @@ -169,7 +168,6 @@ int WINAPI WinMain(HINSTANCE, HINSTANCE, char *, int) { wWinMainCRTStartup(); } -#endif // _UNICODE CMainWindow::CMainWindow() { diff --git a/src/msw/ole/activex.cpp b/src/msw/ole/activex.cpp index 763354c460..f4f507ab55 100644 --- a/src/msw/ole/activex.cpp +++ b/src/msw/ole/activex.cpp @@ -490,11 +490,7 @@ public: HRESULT STDMETHODCALLTYPE LockContainer(BOOL) override {return S_OK;} //********************IOleItemContainer*************************** HRESULT STDMETHODCALLTYPE - #if defined(_UNICODE) GetObjectW - #else - GetObjectA - #endif (LPOLESTR pszItem, DWORD, IBindCtx *, REFIID, void ** ppvObject) override { if (pszItem == nullptr || ppvObject == nullptr) diff --git a/src/msw/ole/uuid.cpp b/src/msw/ole/uuid.cpp index 437152baf4..89c4aa3f56 100644 --- a/src/msw/ole/uuid.cpp +++ b/src/msw/ole/uuid.cpp @@ -42,11 +42,7 @@ Uuid::Uuid(const Uuid& uuid) // force the string to be allocated by RPC // (we free it later with RpcStringFree) -#ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); -#else - UuidToString(&m_uuid, &m_pszUuid); -#endif // allocate new buffer m_pszCForm = new wxChar[UUID_CSTRLEN]; @@ -61,11 +57,7 @@ Uuid& Uuid::operator=(const Uuid& uuid) // force the string to be allocated by RPC // (we free it later with RpcStringFree) -#ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); -#else - UuidToString(&m_uuid, &m_pszUuid); -#endif // allocate new buffer if not done yet if ( !m_pszCForm ) @@ -90,11 +82,7 @@ Uuid::~Uuid() // this string must be allocated by RPC! // (otherwise you get a debug breakpoint deep inside RPC DLL) if ( m_pszUuid ) -#ifdef _UNICODE RpcStringFree((unsigned short **)&m_pszUuid); -#else - RpcStringFree(&m_pszUuid); -#endif // perhaps we should just use a static buffer and not bother // with new and delete? @@ -108,11 +96,7 @@ void Uuid::Set(const UUID &uuid) m_uuid = uuid; // get string representation -#ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); -#else - UuidToString(&m_uuid, &m_pszUuid); -#endif // cache UUID in C format UuidToCForm(); @@ -133,20 +117,12 @@ void Uuid::Create() bool Uuid::Set(const wxChar *pc) { // get UUID from string -#ifdef _UNICODE if ( UuidFromString(reinterpret_cast(const_cast(pc)), &m_uuid) != RPC_S_OK ) -#else - if ( UuidFromString((wxUChar *)pc, &m_uuid) != RPC_S_OK) -#endif // failed: probably invalid string return false; // transform it back to string to normalize it -#ifdef _UNICODE UuidToString(&m_uuid, (unsigned short **)&m_pszUuid); -#else - UuidToString(&m_uuid, &m_pszUuid); -#endif // update m_pszCForm UuidToCForm(); diff --git a/src/msw/version.rc b/src/msw/version.rc index e46f7f2a98..0829acb058 100644 --- a/src/msw/version.rc +++ b/src/msw/version.rc @@ -28,13 +28,8 @@ // http://msdn.microsoft.com/en-us/library/aa381049(VS.85).aspx for the full // list of languages and charsets #define LANG 0x0409 -#ifdef _UNICODE - #define CHARSET 0x4b0 - #define LANG_WITH_CHARSET "040904b0" -#else - #define CHARSET 0 - #define LANG_WITH_CHARSET "04090000" -#endif +#define CHARSET 0x4b0 +#define LANG_WITH_CHARSET "040904b0" #ifdef WXMAKINGDLL_BASE #define WXLIBDESC "base"