From 47dc2e09c57d9beab71ef1d7cc4210ab27bc8796 Mon Sep 17 00:00:00 2001 From: Kelvin Lee Date: Sat, 7 Nov 2020 23:21:40 +1100 Subject: [PATCH] AVRO-2955: Fix VS2010 support. --- lang/c/CMakeLists.txt | 23 ++++++++++++----------- lang/c/README.maintaining_win32.txt | 6 ++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lang/c/CMakeLists.txt b/lang/c/CMakeLists.txt index abc1f2a4ec3..b12c2b52dc0 100644 --- a/lang/c/CMakeLists.txt +++ b/lang/c/CMakeLists.txt @@ -107,17 +107,18 @@ if(CMAKE_COMPILER_IS_GNUCC) add_compile_options(-W -Wall) endif(CMAKE_COMPILER_IS_GNUCC) -if (MSVC) -add_definitions(-D_CRT_SECURE_NO_WARNINGS) -if(MSVC_VERSION LESS 1700) - # Compile as C++ to allow declarations after statements. (C11 feature) - add_compile_options(/TP) - # However, this does not work as the code is not C++ compliant either. - message(FATAL_ERROR "MSVC_VERSION(${MSVC_VERSION}) is not supported.") -elseif(MSVC_VERSION LESS 1920) -else() - add_compile_options(/std:c11) -endif(MSVC_VERSION LESS 1700) +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + if(MSVC_VERSION LESS 1700) + # VS2010 and earlier. + # Compile as C++ to allow declarations after statements. (C11 feature) + add_compile_options(/TP) + elseif(MSVC_VERSION LESS 1920) + # VS2013|VS2015|VS2017 + else() + # VS2019 and later. + add_compile_options(/std:c11) + endif(MSVC_VERSION LESS 1700) endif(MSVC) # Uncomment to allow missing fields in the resolved-writer diff --git a/lang/c/README.maintaining_win32.txt b/lang/c/README.maintaining_win32.txt index 13dcc64867a..237311ced29 100644 --- a/lang/c/README.maintaining_win32.txt +++ b/lang/c/README.maintaining_win32.txt @@ -31,10 +31,8 @@ Limitations of Windows Build: statements were removed, that Avro-C would compile under Microsoft's C compiler also. I have not tried this. - Note: This is referring to a C11 feature which is supported from VS2013 - onward. However, compiling as C++ does not work as the code is not C++ - compliant either. Basically, VS2010 or before just cannot be supported - unless significant changes are made to the code. + Note: This is referring to a C11 feature which is supported in VS2013 + and later. 2. The shared library, i.e. DLL, for avro has not been built. There are instructions on how to build DLLs using CMake at