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

syntax check incorrect for some C++ library #8487

Closed
yuanyangwangTJ opened this issue Dec 5, 2021 · 5 comments
Closed

syntax check incorrect for some C++ library #8487

yuanyangwangTJ opened this issue Dec 5, 2021 · 5 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release

Comments

@yuanyangwangTJ
Copy link

yuanyangwangTJ commented Dec 5, 2021

Bug type: Language Service

Describe the bug

  • OS and Version: win10
  • VS Code Version: latest
  • C/C++ Extension Version: v1.8.0
  • 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).
    I use a C++ json library -- nlohmann/json, which is written by modern C++, and I install it by msys2 on win. But when I use it, vscode can't find all member function of this library, just part of it. Actually, my code can be compiled and run. It's terrible to see errors that do not exist in code. May it's my fault for intelliSense configuration? It's worth mentioning that when I open my code by vim editor with a autocomplete plugin YouCompleteMe, there is no error. So where is the problem?

Expected behavior

Vscode with C++ extension can find correct API and member function of library.

Code sample and logs

  • Code sample
#include <iostream>
#include <nlohmann/json.hpp>

using json = nlohmann::json;

int main()
{
    json j;
    j.push_back("foo");
    return 0;
}
  • Configurations in c_cpp_properties.json
{
    "name": "MSYS2",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "windowsSdkVersion": "10.0.18362.0",
    "compilerPath": "C:/msys64/mingw64/bin/g++.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-gcc-x64",
    "mergeConfigurations": false
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
class "nlohmann::basic_json<std::map, std::vector, std::string, bool, int64_t, uint64_t, double, std::allocator, nlohmann::adl_serializer, std::vector<uint8_t, std::allocator<uint8_t>>>" has no member "push_back"

Screenshots

image-20211205105759926

Additional context

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Dec 6, 2021

The bug doesn't repro with 1.7.1 -- a workaround is to change C_Cpp.updateChannel to "Default" instead of "Insiders" to downgrade to 1.7.1.

This is most likely a duplicate of #8475 .

@sean-mcmanus sean-mcmanus added bug Language Service regression A bug that didn't exist in a previous release labels Dec 6, 2021
@yuanyangwangTJ
Copy link
Author

The bug doesn't repro with 1.7.1 -- a workaround is to change C_Cpp.updateChannel to "Default" instead of "Insiders" to downgrade to 1.7.1.

This is most likely a duplicate of #8475 .

Thanks, v1.7.1 is ok. Hope this extension can support more C++ feature in v1.8 !

@sean-mcmanus sean-mcmanus added this to the Tracking milestone Dec 7, 2021
@sean-mcmanus
Copy link
Collaborator

@yuanyangwangTJ FYI, you can add "-fno-ms-extensions" to compilerArgs with 1.8.0-insiders2 to work around this bug, which was "triggered" by a 1.8.0-insiders bug fix that added -fms-extensions (which is the default for mingw gcc).

@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Dec 14, 2021
@sean-mcmanus
Copy link
Collaborator

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.8.0-insiders3 or 1.8.0 (via using VS Code's "Pre-Release Version" UI or https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools&ssr=false#version-history ).

Unless you're explicitly adding -fms-extensions, in which case that bug fix is still pending (#8353 ).

@sean-mcmanus
Copy link
Collaborator

The underlying issue is now fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/1.8.1 , i.e. you can add back -fms-extensions -- however you may still hit other bugs when -fms-extensions are used (#8353).

@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release
Projects
None yet
Development

No branches or pull requests

2 participants