From bf95874c2dde1c4f8b9bd599f1898e0960b19839 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 22 May 2024 20:48:04 +0300 Subject: [PATCH] [REACTOS] Improve handling of non-standard names - Link oldnames instead of defining names - Define _CRT_DECLARE_NONSTDC_NAMES to 1 where needed - Remove header hacks --- base/services/dhcpcsvc/CMakeLists.txt | 2 +- dll/3rdparty/libtirpc/CMakeLists.txt | 3 ++- dll/cpl/appwiz/CMakeLists.txt | 2 +- dll/win32/kernel32/winnls/string/locale.c | 1 + dll/win32/shell32/CMakeLists.txt | 2 +- dll/win32/wininet/CMakeLists.txt | 3 +-- drivers/filesystems/ext2/CMakeLists.txt | 2 +- .../rosapps/applications/cmdutils/touch/CMakeLists.txt | 1 + modules/rosapps/applications/net/ncftp/CMakeLists.txt | 7 ++++++- sdk/include/crt/crtdefs.h | 7 +++---- sdk/include/crt/string.h | 9 --------- sdk/lib/3rdparty/stlport/CMakeLists.txt | 5 +++++ sdk/lib/3rdparty/zlib/CMakeLists.txt | 1 + sdk/lib/gcc-compat/CMakeLists.txt | 2 +- sdk/lib/rtl/actctx.c | 1 + sdk/tools/wpp/CMakeLists.txt | 5 +++++ 16 files changed, 31 insertions(+), 22 deletions(-) diff --git a/base/services/dhcpcsvc/CMakeLists.txt b/base/services/dhcpcsvc/CMakeLists.txt index add998f0f5a..1726d94bd09 100644 --- a/base/services/dhcpcsvc/CMakeLists.txt +++ b/base/services/dhcpcsvc/CMakeLists.txt @@ -1,5 +1,4 @@ -add_definitions(-Dtzset=_tzset) include_directories(include) spec2def(dhcpcsvc.dll dhcpcsvc.spec ADD_IMPORTLIB) @@ -27,6 +26,7 @@ add_library(dhcpcsvc MODULE dhcpcsvc.rc ${CMAKE_CURRENT_BINARY_DIR}/dhcpcsvc.def) +target_link_libraries(dhcpcsvc oldnames) set_module_type(dhcpcsvc win32dll) add_importlibs(dhcpcsvc ws2_32 iphlpapi advapi32 msvcrt kernel32 ntdll) add_pch(dhcpcsvc include/rosdhcp.h "${PCH_SKIP_SOURCE}") diff --git a/dll/3rdparty/libtirpc/CMakeLists.txt b/dll/3rdparty/libtirpc/CMakeLists.txt index a0cb36ce8eb..ce96dc50dbf 100644 --- a/dll/3rdparty/libtirpc/CMakeLists.txt +++ b/dll/3rdparty/libtirpc/CMakeLists.txt @@ -2,7 +2,7 @@ spec2def(libtirpc.dll libtirpc/libtirpc.spec ADD_IMPORTLIB) remove_definitions(-D_WIN32_WINNT=0x502) add_definitions(-D_WIN32_WINNT=0x600) -add_definitions(-DUNICODE -D_WIN32 -DPORTMAP -Dstrdup=_strdup -D_CRT_NONSTDC_NO_DEPRECATE=1) +add_definitions(-DUNICODE -D_WIN32 -DPORTMAP -D_CRT_NONSTDC_NO_DEPRECATE=1) include_directories(${REACTOS_SOURCE_DIR}/dll/3rdparty/libtirpc/tirpc) @@ -106,6 +106,7 @@ else() endif() set_module_type(libtirpc win32dll) +target_link_libraries(libtirpc oldnames) add_importlibs(libtirpc user32 advapi32 kernel32_vista ws2_32 msvcrt kernel32 ntdll) add_delay_importlibs(libtirpc secur32) add_pch(libtirpc precomp.h SOURCE) diff --git a/dll/cpl/appwiz/CMakeLists.txt b/dll/cpl/appwiz/CMakeLists.txt index 5afee76d7d8..a10165acfc1 100644 --- a/dll/cpl/appwiz/CMakeLists.txt +++ b/dll/cpl/appwiz/CMakeLists.txt @@ -2,7 +2,7 @@ remove_definitions(-D_WIN32_WINNT=0x502) add_definitions(-D_WIN32_WINNT=0x600) -add_definitions(-D__WINESRC__) +add_definitions(-D__WINESRC__ -D_CRT_DECLARE_NONSTDC_NAMES=1) include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine) spec2def(appwiz.cpl appwiz.spec) diff --git a/dll/win32/kernel32/winnls/string/locale.c b/dll/win32/kernel32/winnls/string/locale.c index 2eff3d10b07..f7d327e2142 100644 --- a/dll/win32/kernel32/winnls/string/locale.c +++ b/dll/win32/kernel32/winnls/string/locale.c @@ -30,6 +30,7 @@ DEBUG_CHANNEL(nls); #include "lcformat_private.h" #ifdef __REACTOS__ #include "japanese.h" + #define strcasecmp _stricmp #endif INT WINAPI CompareStringEx(LPCWSTR locale, DWORD flags, LPCWSTR str1, INT len1, diff --git a/dll/win32/shell32/CMakeLists.txt b/dll/win32/shell32/CMakeLists.txt index 7226ba4105d..d7f7672f581 100644 --- a/dll/win32/shell32/CMakeLists.txt +++ b/dll/win32/shell32/CMakeLists.txt @@ -118,7 +118,7 @@ add_typelib(shell32_shldisp.idl) set_source_files_properties(shell32.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/shell32_shldisp.tlb) set_module_type(shell32 win32dll UNICODE) -target_link_libraries(shell32 shellmenu shelldesktop wine uuid recyclebin cpprt atl_classes) +target_link_libraries(shell32 shellmenu shelldesktop wine uuid recyclebin cpprt atl_classes oldnames) add_delay_importlibs(shell32 powrprof shdocvw devmgr winspool.drv winmm mpr uxtheme ole32 oleaut32 userenv browseui version fmifs) add_importlibs(shell32 advapi32 gdi32 user32 comctl32 comdlg32 shlwapi msvcrt kernel32 ntdll) add_dependencies(shell32 stdole2) # shell32_shldisp.tlb needs stdole2.tlb diff --git a/dll/win32/wininet/CMakeLists.txt b/dll/win32/wininet/CMakeLists.txt index 6b041deb423..73449f9f8b4 100644 --- a/dll/win32/wininet/CMakeLists.txt +++ b/dll/win32/wininet/CMakeLists.txt @@ -8,8 +8,7 @@ add_definitions( add_definitions( -D__WINESRC__ - -D_WINE - -Dclose=_close) + -D_WINE) spec2def(wininet.dll wininet.spec ADD_IMPORTLIB) diff --git a/drivers/filesystems/ext2/CMakeLists.txt b/drivers/filesystems/ext2/CMakeLists.txt index e427a1580d3..7f9eb56bcf6 100644 --- a/drivers/filesystems/ext2/CMakeLists.txt +++ b/drivers/filesystems/ext2/CMakeLists.txt @@ -108,7 +108,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "Clang") endif() target_link_libraries(ext2fs memcmp ${PSEH_LIB}) -add_definitions(-D__KERNEL__ -D_CRT_NO_POSIX_ERROR_CODES) +add_definitions(-D__KERNEL__ -D_CRT_NO_POSIX_ERROR_CODES -D_CRT_DECLARE_NONSTDC_NAMES=1) set_module_type(ext2fs kernelmodedriver) add_importlibs(ext2fs ntoskrnl hal) add_pch(ext2fs inc/ext2fs.h SOURCE) diff --git a/modules/rosapps/applications/cmdutils/touch/CMakeLists.txt b/modules/rosapps/applications/cmdutils/touch/CMakeLists.txt index c2d5bd00407..c4212ecdf9b 100644 --- a/modules/rosapps/applications/cmdutils/touch/CMakeLists.txt +++ b/modules/rosapps/applications/cmdutils/touch/CMakeLists.txt @@ -1,5 +1,6 @@ add_executable(touch err.c touch.c touch.rc) +target_compile_definitions(touch PRIVATE _CRT_DECLARE_NONSTDC_NAMES=1) target_link_libraries(touch getopt) set_module_type(touch win32cui) add_importlibs(touch msvcrt kernel32) diff --git a/modules/rosapps/applications/net/ncftp/CMakeLists.txt b/modules/rosapps/applications/net/ncftp/CMakeLists.txt index 7b080fbb687..5124f770c54 100644 --- a/modules/rosapps/applications/net/ncftp/CMakeLists.txt +++ b/modules/rosapps/applications/net/ncftp/CMakeLists.txt @@ -70,7 +70,12 @@ list(APPEND SOURCE add_executable(ncftp ${SOURCE} ncftp.rc) set_module_type(ncftp win32cui) -target_compile_definitions(ncftp PRIVATE HAVE_UTIME_H HAVE_UNISTD_H) +target_compile_definitions(ncftp PRIVATE + HAVE_UTIME_H + HAVE_UNISTD_H + _CRT_DECLARE_NONSTDC_NAMES=1 + strcasecmp=_stricmp +) if(CMAKE_C_COMPILER_ID STREQUAL "GNU") target_compile_options(ncftp PRIVATE -Wno-unused-but-set-variable) endif() diff --git a/sdk/include/crt/crtdefs.h b/sdk/include/crt/crtdefs.h index 6eb0acae37a..2eeb6a7fbd7 100644 --- a/sdk/include/crt/crtdefs.h +++ b/sdk/include/crt/crtdefs.h @@ -33,10 +33,9 @@ #pragma pack(push,_CRT_PACKING) /* Disable non-ANSI C definitions if compiling with __STDC__ */ -//HACK: Disabled -//#if __STDC__ -//#define NO_OLDNAMES -//#endif +#if (!defined _CRT_DECLARE_NONSTDC_NAMES || !_CRT_DECLARE_NONSTDC_NAMES) && (defined _CRT_DECLARE_NONSTDC_NAMES || __STDC__) +#define NO_OLDNAMES +#endif /** Properties ***************************************************************/ diff --git a/sdk/include/crt/string.h b/sdk/include/crt/string.h index aaa9c52f038..db962ae1c27 100644 --- a/sdk/include/crt/string.h +++ b/sdk/include/crt/string.h @@ -575,9 +575,6 @@ extern "C" { _In_z_ const char *_Str, _In_ size_t _MaxCount); -// __CRT_INLINE int __cdecl strncasecmp (const char *__sz1, const char *__sz2, size_t __sizeMaxCompare) { return _strnicmp (__sz1, __sz2, __sizeMaxCompare); } -// __CRT_INLINE int __cdecl strcasecmp (const char *__sz1, const char *__sz2) { return _stricmp (__sz1, __sz2); } - _CRTIMP _CRT_NONSTDC_DEPRECATE(_strnset) char* @@ -1138,11 +1135,5 @@ extern "C" { } #endif -// HACK -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#define stricmp _stricmp -#define wcsicmp _wcsicmp - #include #endif diff --git a/sdk/lib/3rdparty/stlport/CMakeLists.txt b/sdk/lib/3rdparty/stlport/CMakeLists.txt index 2fb3f5643a5..1643459fd9c 100644 --- a/sdk/lib/3rdparty/stlport/CMakeLists.txt +++ b/sdk/lib/3rdparty/stlport/CMakeLists.txt @@ -51,6 +51,11 @@ target_compile_definitions(stlport PRIVATE _STLP_USE_EXCEPTIONS _DLL __USE_CRTIMP _BUILD_STLPORT NATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/sdk/include/c++) +target_compile_definitions(stlport PUBLIC + _CRT_DECLARE_NONSTDC_NAMES=1 + _CRT_NONSTDC_NO_DEPRECATE +) + target_include_directories(stlport INTERFACE "$<$:${REACTOS_SOURCE_DIR}/sdk/include/c++/stlport>") target_compile_definitions(stlport INTERFACE "$<$:NATIVE_CPP_INCLUDE=${REACTOS_SOURCE_DIR}/sdk/include/c++>") set_target_cpp_properties(stlport WITH_EXCEPTIONS WITH_RTTI) diff --git a/sdk/lib/3rdparty/zlib/CMakeLists.txt b/sdk/lib/3rdparty/zlib/CMakeLists.txt index a10936ea05a..af42ff93b48 100644 --- a/sdk/lib/3rdparty/zlib/CMakeLists.txt +++ b/sdk/lib/3rdparty/zlib/CMakeLists.txt @@ -34,6 +34,7 @@ list(APPEND MINIZIP_SOURCE if(CMAKE_CROSSCOMPILING) add_library(zlib ${SOURCE} ${SOLO_SOURCE}) + target_link_libraries(zlib oldnames) target_include_directories(zlib PRIVATE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib) add_library(zlib_solo ${SOLO_SOURCE}) target_compile_definitions(zlib_solo PRIVATE Z_SOLO) diff --git a/sdk/lib/gcc-compat/CMakeLists.txt b/sdk/lib/gcc-compat/CMakeLists.txt index ef0f86354c2..6e2b269f802 100644 --- a/sdk/lib/gcc-compat/CMakeLists.txt +++ b/sdk/lib/gcc-compat/CMakeLists.txt @@ -12,4 +12,4 @@ set_target_cpp_properties(stdc++compat WITH_EXCEPTIONS) add_dependencies(stdc++compat xdk) target_link_libraries(stdc++compat libmsvcrt) remove_target_compile_option(stdc++compat "$<$,$>>>:-nostdinc>") -target_compile_definitions(stdc++compat PRIVATE "$<$:PAL_STDCPP_COMPAT>") +target_compile_definitions(stdc++compat PRIVATE "$<$:PAL_STDCPP_COMPAT>" _CRT_DECLARE_NONSTDC_NAMES=1) diff --git a/sdk/lib/rtl/actctx.c b/sdk/lib/rtl/actctx.c index 4eb9579edff..540d5ff511f 100644 --- a/sdk/lib/rtl/actctx.c +++ b/sdk/lib/rtl/actctx.c @@ -37,6 +37,7 @@ #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) #define wcsnicmp _wcsnicmp #define swprintf _snwprintf +#define wcsicmp _wcsicmp #undef RT_MANIFEST #undef CREATEPROCESS_MANIFEST_RESOURCE_ID diff --git a/sdk/tools/wpp/CMakeLists.txt b/sdk/tools/wpp/CMakeLists.txt index 11999c26949..7802b8debeb 100644 --- a/sdk/tools/wpp/CMakeLists.txt +++ b/sdk/tools/wpp/CMakeLists.txt @@ -1,4 +1,9 @@ +add_definitions( + -D_CRT_DECLARE_NONSTDC_NAMES=1 + -D_CRT_NONSTDC_NO_DEPRECATE +) + if(MSVC) if(MSVC_VERSION LESS 1900) add_definitions(