admin管理员组文章数量:1303496
I'm using VSCode as an IDE. On windows, with cl compiler available, intellisense does not evaluate correctly the __cplusplus
macro. I set intellisense to use C++20 (basically like in: How can I change the version of the C++ language standard used in VS Code?). But I've got a section of code between:
#if __cplusplus >= 202002L
...
#endif
and it is grayed (not parsed by intellisense, which seems to use 199711L
).
How can I fix that?
NB On the other hand my compilation setting works just fine and evaluate correctly the macro.
I'm using VSCode as an IDE. On windows, with cl compiler available, intellisense does not evaluate correctly the __cplusplus
macro. I set intellisense to use C++20 (basically like in: How can I change the version of the C++ language standard used in VS Code?). But I've got a section of code between:
#if __cplusplus >= 202002L
...
#endif
and it is grayed (not parsed by intellisense, which seems to use 199711L
).
How can I fix that?
NB On the other hand my compilation setting works just fine and evaluate correctly the macro.
Share Improve this question edited Feb 28 at 9:52 Oersted asked Feb 10 at 12:38 OerstedOersted 2,7766 silver badges28 bronze badges 5- @sweenish you're right, question edited. – Oersted Commented Feb 10 at 14:57
- NB IMHO, my question is not a dup as the proposed duplicate are about cl setting, not intellisense configuration for vscode (though both subject are linked). I personally use the option given in the answer through cmake, for actual compilation. It didn't occurred to me that they were also needed for intellisense. – Oersted Commented Feb 10 at 16:20
- Its been edited beyond repair – wahwahwah Commented Feb 23 at 19:42
- This has little to do with VS Code, and more to do with MSVC, Microsoft's compiler. But I say just use cmake at this point. Very few people should be bothering with compiler/linker flags directly anymore. – sweenish Commented Feb 27 at 17:50
- @sweenish my edit was unclear also though the title actually points to vscode. I'm editing again. – Oersted Commented Feb 28 at 9:49
1 Answer
Reset to default 2By finding lots of discussions on the subject of intellisense and __cplusplus
macro it seemed to be related to /Zc:__cplusplus
compiler option.
It is not assumed by intellisense and must be added explicitly. In vscode settings UI:
Extension/C/C++/Intellisense/C_Cpp › Default: Compiler Args
just add /Zc:__cplusplus
.
update: adding /permissive-
is also a good idea, though not required for the __cplusplus
issue. (Thanks to @Eljay for his comment)
本文标签: cC20 set for intellisense in vscode but cplusplus does notStack Overflow
版权声明:本文标题:c++ - C++20 set for intellisense in vscode but __cplusplus does not - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741716459a2394139.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论