From a6e3daba9ec5b87e8acbeb79cdea1cd1d9ebe8d5 Mon Sep 17 00:00:00 2001 From: Adrien Bertrand Date: Mon, 16 Jan 2023 10:59:17 +0100 Subject: [PATCH] windows: get the build working further (restrict usage) Note: we cannot simply do a -Drestrict=__restrict because of an internal conflict with the windows SDK --- CMakeLists.txt | 3 --- libticonv/trunk/src/ticonv.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1af1a7f4d..ff73c123b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,9 +118,6 @@ elseif(WIN32) include_directories(${CMAKE_SOURCE_DIR}/win32_config) endif() -# Needed for C++ compat -add_definitions(-Drestrict=__restrict) - # i18n support checking include(FindGettext) include(FindIntl) diff --git a/libticonv/trunk/src/ticonv.h b/libticonv/trunk/src/ticonv.h index c5dbfa4d3..d8e0e866e 100644 --- a/libticonv/trunk/src/ticonv.h +++ b/libticonv/trunk/src/ticonv.h @@ -41,6 +41,13 @@ #ifdef __cplusplus extern "C" { +#endif + +// Work around a Windows SDK issue that prevents us from just using "restrict" directly in both C/C++. +#if defined(__cplusplus) || defined(_MSC_VER) +#define _ticonv_restrict_backup restrict +#undef restrict +#define restrict __restrict #endif /***********************/ @@ -213,6 +220,11 @@ typedef struct /* Deprecated functions */ /************************/ +#if defined(__cplusplus) || defined(_MSC_VER) +#undef restrict +#define restrict _ticonv_restrict_backup +#endif + #ifdef __cplusplus } #endif