From 3bdaa53725238cff62fc02fdc3dd155a36a70293 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 17 May 2016 12:38:35 +0000 Subject: [PATCH] MSVC: expand C99's `inline` to MSVC's `__inline`. This is not done for C++ as C++ has a proper inline keyword, and MSVC's C++ standard library will not like it becoming a macro. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73a3af2d..401d7113 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,13 @@ if(WIN32) -D_UNICODE) endif() +if(MSVC) + # Many versions of MSVC do not have the (C99) inline keyword, instead + # they have their own __inline; this breaks `static inline` functions. + # We do not want to care and so we fix this with a definition. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline") +endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")