Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC uses C++ compiler for C code? #1250

Open
sphaero opened this issue Jun 4, 2020 · 4 comments
Open

MSVC uses C++ compiler for C code? #1250

sphaero opened this issue Jun 4, 2020 · 4 comments

Comments

@sphaero
Copy link
Contributor

sphaero commented Jun 4, 2020

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?

@sphaero
Copy link
Contributor Author

sphaero commented Jun 4, 2020

Btw, when commenting those lines czmq builds fine, with some conversion warnings though.

@sappo
Copy link
Member

sappo commented Jun 4, 2020

Git blame tells my I'm responsible for that particular piece of configuration 😆

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!

@sphaero
Copy link
Contributor Author

sphaero commented Jun 4, 2020

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?

@sphaero
Copy link
Contributor Author

sphaero commented Sep 29, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants