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.
This commit is contained in:
whitequark 2016-05-17 12:38:35 +00:00
parent ae60187322
commit 3bdaa53725

View File

@ -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}")