zproject
zproject copied to clipboard
MSVC uses C++ compiler for C code?
Why is in Cmake the compiler forced to use the C++ compiler?
if (WIN32)
#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
enable_language(CXX)
file(GLOB sources "${SOURCE_DIR}/src/*.c")
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
endif()
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()
This gives errors when using ifdef cplusplus from what I've seen so far.
What was the reasoning behind this? Is it really needed?
Btw, when commenting those lines czmq builds fine, with some conversion warnings though.
Git blame tells my I'm responsible for that particular piece of configuration :laughing:
This configuration was copied from czmq's CMakefile when zproject came to life. I'm not sure if the comment about MSVC being out of date still holds.
If you feel it unnecessary remove it!
I think MSVC only supports C89 from what I know so indeed it's very old. I could remove it but it probably will influence other projects. In czmq it only generates more warnings which then need to be fixed.
For my purpose it did resolve some issues with the __cplusplus define but I don't know where it will bite us.
Any others thoughts about this?
https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/
Microsoft is working on it apparently