-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My vscode cannot recognize "cout" "endl" etc... (MinGW) #757
Comments
What's more, if you change your intellisense engine to "Tag Parser", the error also changes to that it can't recognize header iostream. By the way, even in the situation like this I can still build and run my cpp file. |
If you are using the "Tag Parser" setting, you need to make sure that the browse.path setting is populated. In your c_cpp_properties.json that you shared, it looks like it is empty. You should add
or similar to your browse.path array. These paths are recursively searched, so use /* if you want to make it non-recursive. |
And the reason that the new IntelliSense didn't work for you is because on Windows the IntelliSense engine compiles the code in Microsoft mode instead of clang/gcc mode. We don't currently expose a setting to change the mode, but there is a workaround I just tested that resolves the squiggles. It requires you to copy |
I tried the second way and it works! And I think the first method can solve it, too. Thanks for your patient explanation. |
Back again, the error shows up once more after I added another head file below iostream. Then I copied some of my IncludePath to browse.path array. It's OK so far, hope that I've solved it once and for all. |
Is everything working for you now? If so, you may close this issue. Otherwise, please let me know if there is something else not working and I can help you resolve it. Thanks. |
Same problem here...
Thanks for the help 😄 |
@igorPhelype, this issue is about MinGW on Windows. Your configuration looks like standard Linux. Can you please open a new issue and provide some detail about your distro and what exactly is not working for you? Thanks. |
Here's my issue: #765 |
The fix for this has been released. Please install version 0.12.0 and let us know if you have any trouble with it. I also wrote up a page recommending a default MinGW configuration that may be of interest to you. |
I used your recommended settings, but there is still problems with things like freopen,scanf,printf |
Can you try adding |
I solved it on my machine with these steps :
So after adding all include paths this should work fine and mine file looked like this :
Note : You may also need to install clang on your linux machine |
@bobbrow I get the following 3 errors in VS Code from Win10:
after add the "includePath" and "browse"->"path" as the result of "gcc -v -E -x c++ -", as following: I changed "intelliSenseMode" to "clang-x64", but other errors showing up. I add "GNUC=6" in "defines" that resolves the last 2 errors, so there is only the first error. |
@lovingjo "msvc-x64" is only for cl.exe (on Windows)...might be better to rename it to avoid the confusion. clang-x64 is for clang and gcc, although we have a backlog item to create a gcc mode for cases where clang diverges. What are the errors with clang-x64? You might also consider trying out insiders build and setting your compilerPath setting to the mingw compiler: https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.16.0-insiders , which automatically add all the system includes/defines. Also, it's usually better to create a new issue instead of adding to a closed issue. |
@sean-mcmanus Thank you for your reply!! I just recreate a new c_pp_properties.json, and update as following, all errors or warning are gone, and then I think may be I should add the path result of "gcc -v -E -x c++ -" to browse.path, I try it, and all good. I find that "GNUC=7", "__cdecl=attribute((cdecl))" added in "defines" are the key to resolve the issue, am I right? but I still don't understand the meaning of these two. Could you please tell me some document about the "defines" and why should we keep the order of includePath and browser.path?
|
@lovingjo Yeah, adding the 2 defines is correct. And you want the root paths for your cpp/h files in the browse.path if you want them to be found for Go to Definition (that setting is recursive). If you set your compilerPath with the insider build, then setting the defines shouldn't be necessary (we automatically query the compiler for the builtin includes and defines). I'm not sure I understand what you're asking with your other questions. |
@sean-mcmanus I should keep learning more about coding. Thank you very much!! |
If you have the "IncludePath" and browse.path settings all correct, you can set "intelliSeneseMode" from "msvc-x64" to "clang-x64", which solved my problem. |
I find the same problem... "includePath": [
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
"C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
], this is my include path, but actually with the simple code. #include <cstdio>
int main() {
std::printf("hello world");
} The intelligence seems not able to find printf with a
|
@qqktr can you try setting We do not recommend adding system include paths directly to If that does not resolve your problem, please open a new issue and we will help you troubleshoot. |
From @LiuZHolmes on May 23, 2017 3:11
I already set my cpp_properties correctly(I think),like:
And with the simple code:
there are errors like:
'identifier "cout" is undefined'
'argument list for variable template "endl" is missing'
'identifier "cin" is undefined'
Steps to Reproduce:
1.Install vscode and cpp extensions
2.Set your cpp_properties like me(you may need to change the directory of mingw)
Copied from original issue: microsoft/vscode#27110
The text was updated successfully, but these errors were encountered: