OS: Windows 10 1709
VScode version: VSCode-win32-x64-1.18.1
C/C++ extension version: 0.14.5
compiler: mingw-w64 x86_64-7.2.0
Originally, I get this error message: cannot open source file "bits/c++config.h" (dependency of "iostream")
Then, I read some issue and use command gcc -v -E -x c++ - to get all possible include path and past them all to "includePath" in c_cpp_properties.json.
But now, I get another error:
identifier "cout" is undefined
How can I solve this ? preparing environment of VScode has taken me too much time :(
my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win64",
"includePath": [
"${workspaceRoot}",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/x86_64-w64-mingw32",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/backward",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/include-fixed",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/include"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/x86_64-w64-mingw32/include",
"C:/Program Files/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
Your Win64 configuration setting don't appear to be correct for mingw on Windows. See https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/MinGW.md . Your intelliSenseMode should be clang-x64 and you're missing some defines. Are you able to get it to work now?
First, very sorry for response this so late. I am so busy in this period that I forgot this issue :(
After some correction, I get a new c_cpp_properties.json. But still get same problem, "identifier cin is undefined". And other object like vector also has same problem.
I have try to fix my properties document as same as possible to the json document you posted me.
If I do anything wrong, please directly point out.
Thank you very much.
It could be due to some missing defines. Our next 0.16.0 release might fix this after you set the new compilerPath property.
Can you try the cpptools-win32.vsix at https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.16.0-insiders2 and set your compilerPath to see if that fixes it?
I updated the cpptools to latest vesion 0.16.1 ,reinstalled my mingw-64 and reset my includePath according:
https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/MinGW.md
Finally, my vscode run perfectly. Thanks God and you.
It took me so long to make it work.
Attached file is my latest c_cpp_properites.json file, hope this can help you to improve this project.
c_cpp_properties.zip
Oh, you may also want to consider setting the compilerPath to get the correct compiler defines for you compiler. With the c_cpp_properties.json provided, it is not expected that 0.16.0-1 would have fixed anything.
@sean-mcmanus The documentation on VS Code website needs to be corrected; that is why some people probably have a problem with this:
https://code.visualstudio.com/docs/languages/cpp#_getting-started
{
"name": "Win32",
"includePath": [
"${workspaceFolder}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceFolder}",
"C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
@HunderlineK Oh, that's odd. That doc example would have never worked correctly, even without the new compilerPath. I don't think that example c_cpp_properties.json was intended to be used as an example of configuring IntelliSense with a mingw project -- looks like just an example of adding a path to the browse.path. Those docs were last updated 8 months ago and the "Update browse.path setting" UI doesn't even exist anymore. Hopefully, people don't follow those docs too closely :). I'll try to get it updated/fixed, but the person who normally updates the doc is OOF this week.
@HunderlineK Docs have been updated.
This issue is still not fixed in vscode
@vikrantsingh47 cout being undefined is just a symptom. Can you file a new issue with more repro info?
Most helpful comment
@HunderlineK Docs have been updated.