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

Code analysis reports issue with macro __has_include__ even though g++/clang++ don't complain #9575

Closed
nicsav opened this issue Jul 13, 2022 · 6 comments
Assignees
Labels
bug Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix verified Bug has been reproduced
Milestone

Comments

@nicsav
Copy link

nicsav commented Jul 13, 2022

Bug type: Language Service

Describe the bug

  • OS and Version: Windows 11
  • VS Code Version: 1.69.1
  • C/C++ Extension Version: 1.10.8
  • Other extensions you installed (and if the issue persists after disabling them):
  • If using SSH remote, specify OS of remote machine:
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

Steps to reproduce

  1. open project in attached file
  2. open has_include,cpp
  3. press ctrl+shift+p
  4. select 'C/C++: run analysis on active file'
  5. see error reported:
    [{
    "resource": "/home/nick/has_include/has_include.cpp",
    "owner": "clang-tidy",
    "code": "clang-diagnostic-error",
    "severity": 8,
    "message": "function-like macro 'has_include' is not defined",
    "source": "C/C++",
    "startLineNumber": 3,
    "startColumn": 5,
    "endLineNumber": 3,
    "endColumn": 18
    }]

Expected behavior

The code analysis should not report this as the code compiles cleanly with g++/clang++.

Code sample and logs

  • Code sample

See attached .tar.gz for project containing source and settings to repro. It's run on WSL Ubuntu 20.04.

  • Configurations in c_cpp_properties.json

  • Logs from running C/C++: Log Diagnostics from the VS Code command palette

  • Logs from the language server logging

Screenshots

I've attached a screenshot showing the error.

Additional context

has_include
has_include.tar.gz

@nicsav
Copy link
Author

nicsav commented Jul 13, 2022

language logs.txt

@nicsav
Copy link
Author

nicsav commented Jul 13, 2022

c++ logs.txt

@nicsav
Copy link
Author

nicsav commented Jul 13, 2022

The project does not appear to have a c_cpp_properties.json

@sean-mcmanus sean-mcmanus self-assigned this Jul 14, 2022
@sean-mcmanus sean-mcmanus added Language Service Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. verified Bug has been reproduced labels Jul 14, 2022
@channingxiao
Copy link

got same issues with
vscode 1.69.1, cpptooles v1.10.8
at every single class definion cpp file, the file line to include it's header file, it complained "
Error while processing C/C++(clang-diagnostic-error)[Ln1,Col1]
statx.h[Ln30,Col 6]: function-line macro' has_include' is not defined

"
Uploading image.png…

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Jul 15, 2022

The issue repros with gcc 9, but not 10. It's caused by the macro -D__has_include(STR)=__has_include__(STR) which clang (or gcc 10+) isn't able to process, but gcc 9 is. We can fix it by filtering that out (which we were already doing for IntelliSense processing as well).

@sean-mcmanus sean-mcmanus added this to the 1.11.3 milestone Jul 15, 2022
@sean-mcmanus sean-mcmanus added quick fix fixed Check the Milestone for the release in which the fix is or will be available. labels Jul 15, 2022
@sean-mcmanus
Copy link
Collaborator

Fixed with 1.11.3 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.11.3

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Code Analysis Related to integration with clang-tidy, cppcheck, cl.exe /analyze, etc. fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix verified Bug has been reproduced
Projects
None yet
Development

No branches or pull requests

3 participants