Skip to content

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

@sphaero

Description

@sphaero

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions