Skip to content
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

C++ Syntax error checking not working #2164

Closed
rickstaa opened this issue Jun 21, 2018 · 10 comments
Closed

C++ Syntax error checking not working #2164

rickstaa opened this issue Jun 21, 2018 · 10 comments

Comments

@rickstaa
Copy link

rickstaa commented Jun 21, 2018

Type: LanguageService

Dear Developers, I just switched from sublime text to visual studio code and I really love the program. I, however, have one thing I miss in the program namely c++ code linting. I looked on the issues forum but I can however not find a way to enable this. My question is, therefore, does visual studio code support c++ code linting to warn me on potential syntax errors before compiling. I have it working with the cppcheck extension but the workflow is far from optimal. Is there a better way to have visual code check the cpp files everytime I save my file?

Describe the bug

  • OS and Version: Linux ubuntu Bionic beaver 18.04

  • VS Code Version: Version 1.24.1

  • C/C++ Extension Version: Version 0.17.4: May 31, 2018

  • Other extensions you installed (and if the issue persists after disabling them): vscodevim.vim, pkief.material-icon-theme, jerryhong.autofilename, mitaki28.vscode-clang, austin.code-gnu-glob, twxs.cmake, vector-of-bool.cmake-tools, nonylene.dark-molokai-theme, eamodio.gitlens, ajshort.msg, pijar.ros-snippets.

  • A clear and concise description of what the bug is.
    When making syntax errors see picture below in sublime text I get a red wavy underline under the syntax error. In visual studio code, I found no way to get the same behaviour.

To Reproduce
Steps to reproduce the behavior:
Provide a code sample including configuration files such as c_cpp_properties.json

  1. Go to new cpp file.
  2. code some syntax with an error I ommited the ; and } symbols.
  3. save the file
  4. Find out that there is no error or warning.

What I tried

  • Installing the cppcheck extension
  • Installing the c/C++ advanced lint extension
  • Checking if C_Cpp.intelliSenseEngine: "Default" was set and "errorSquiggles to Enabled".

Expected behavior
A red error underline when I make a syntax error.

Screenshots
image

Additional context

@sean-mcmanus
Copy link
Collaborator

Our extensions supports error squiggles -- I believe the other C++ extensions you have installed are causing a conflict. You should try disabling them.

@sean-mcmanus sean-mcmanus added external more info needed The issue report is not actionable in its current state labels Jun 21, 2018
@rickstaa
Copy link
Author

Dear Sean,

Thanks a lot for you very fast reply. I removed all the other extensions and restarted visual studio code. If I understand you correctly this should give a lot of syntax errors right?

image

Thanks a lot in advance,

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jun 21, 2018

Yeah, something strange is going on. What does it show in the Output window, C/C++ panel? You may need to set the C_Cpp.loggingLevel to "Debug". Do other features like Go to Definition or Format Document work? Is the file encoding UTF-8?

@rickstaa
Copy link
Author

Thanks a lot for looking into it except from these issues I think you build an amazing app. I enabled "Debug" like you said and checked the output of the C/C++ panel I attached the output below.

  • The format document command works like a charm.
  • The go to definition only works on my own defined classes not on any of the standard libraries or included headers. It does also not work on structs I define in the same file.

image

Output C/C++ panel
IntelliSense Engine = Tag Parser.
The extension will use the Tag Parser for IntelliSense when #includes don't resolve.
Autocomplete is enabled.
Error squiggles are enabled.
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
File exclude: **/.vscode
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/.vscode
Code browsing service initialized
Folder: /usr/lib/llvm-6.0/lib/clang/6.0.1/include/ will be indexed
Folder: /usr/local/include/ will be indexed
Folder: /usr/lib/gcc/x86_64-linux-gnu/7/include/ will be indexed
Folder: /usr/include/ will be indexed
Folder: /home/ricks/Desktop/ will be indexed
Discovering files...
Processing folder (recursive): /usr/lib/llvm-6.0/lib/clang/6.0.1/include/
Processing folder (recursive): /usr/local/include/
Processing folder (recursive): /usr/lib/gcc/x86_64-linux-gnu/7/include/
Processing folder (recursive): /usr/include/
Processing folder (recursive): /home/ricks/Desktop/
Discovering files: 6123 file(s) processed
0 file(s) removed from database
Done discovering files.
Parsing open files...
Done parsing open files.
Parsing remaining files...
Parsing: 0 files(s) processed
Done parsing remaining files.
IntelliSense Engine = Tag Parser.
The extension will use the Tag Parser for IntelliSense when #includes don't resolve.
Autocomplete is enabled.
Error squiggles are enabled.

@sean-mcmanus
Copy link
Collaborator

You need to change your "intelliSenseEngine" setting to "Default" instead of "Tag Parser".

@rickstaa
Copy link
Author

O your right that's it! Sorry for taking your time. I don't know how it happend but in the user settings file there is a command overwriting the intelliSenseEngine settings. Can this be caused by installing a lot of plugins?

@sean-mcmanus
Copy link
Collaborator

It's possible for another extension to change/modify our settings...I haven't heard of any extensions that do that though. If enabling an extension causes the setting to change back to Tag Parser you may need to disable that extension.

@sean-mcmanus sean-mcmanus added by design and removed more info needed The issue report is not actionable in its current state labels Jun 21, 2018
@rickstaa
Copy link
Author

Sean one more question If I may. Why does the syntax checker not work in the following code document? I think it is due to the fact that the header files were not found. Can I disable this behaviour that visual code doesn't display errors when a header file is not found? I am working on a singularity image so the header files are there but just not seen by visual code.

Thank a lot in advance,
Greetings,

CODE
code

@sean-mcmanus
Copy link
Collaborator

Yes, you can change the "intelliSenseFallbackMode" to "Disabled", but from your screenshot I don't see the green squiggle that is supposed to appear under missing headers. If you look for the Microsoft.VSCode.CPP.IntelliSense.Msvc process and it appears and then disappears after opening the file, then it means something in the headers is causing a crash during parsing.

@rickstaa
Copy link
Author

Ah sorry, I accidentally only send you the screenshot in which it was working. But your answer was the one I was looking for thanks a lot!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants