microsoft / microsoft/vscode-cpptools
Decouple automatically setting the `_WIN32` macro when the `-fms-extensions` compiler argument is specified
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
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
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the behavior with the supplied c_cpp_properties.json on Linux, using compilerArgs with -fms-extensions, and inspect how compiler arguments and predefined macros are handled. Done means Microsoft extensions remain enabled without automatically defining _WIN32, while the existing configuration continues to parse the anonymous structs correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100