Skip to content

Decouple automatically setting the _WIN32 macro when the -fms-extensions compiler argument is specified #13188

Open
@ddritzenhoff

Description

@ddritzenhoff

Feature Request

Hey, happy new year :)

As the title suggests, I'd love a way to stop the _WIN32 macro from being automatically defined when the -fms-extensions compiler argument is specified. I'm currently working on the MsQuic repository, which supports multiple different platforms (e.g. Windows, Linux, MacOS), and it uses some features that aren't native to clang c17 such as compounded anonymous structs (seen here and used here). You can fix this problem by adding -fms-extensions to the compiler arguments, which implicitly defines _WIN32. I’m working on MsQuic for Linux, so I get cannot open source file "windows.h” errors as a consequence. Leaving -fms-extensions out also doesn’t work, as then the compounded anonymous structs aren’t recognized anymore and generate errors themselves.

Similar issues can be found in #2432 and #2363, but it seems as if nobody has had exactly the one I'm facing now. Adding -U_WIN32 to the compiler arguments also doesn't seem to work.

  • OS and Version: Linux Ubuntu 24.04.1 LTS
  • VS Code Version: 1.96.3
  • C/C++ Extension Version: 1.22.11
  • Other extensions you installed (and if the issue persists after disabling them): It's irrelevant, as the related issue is based on C extensions.

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/libnl3/**",
                "/usr/include/bpf",
                "/usr/include/xdp"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "QUIC_EVENTS_STUB",
                "QUIC_LOGS_STUB",
                "CX_PLATFORM_LINUX"
            ],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-clang-x64",
            "compilerArgs": [
                "-fms-extensions"
            ]
        }
    ],
    "version": 4
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions