Skip to content

operator "" sv doesn't get recognized even though using namespace std::string_view_literals; is present #5681

Closed

Description

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 2004
  • VS Code Version: 1.46.1
  • C/C++ Extension Version: 0.28.3
  • Other extensions you installed (and if the issue persists after disabling them): Babel Javascript, CodeLLDB, PlatformIO IDE, PowerShell Preview, Python, IntelliCode. Issue persists after disabling all.
  • Does this issue involve using SSH remote to run the extension on a remote machine?: No
  • 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).

Trying to use sv literal gives me an error user-defined literal operator not found even though using namespace std::string_view_literals is present, and the code does compile successfully. Using llvm-mingw toolchain

Steps to reproduce

Code for reproduction:

#include <string_view>

using namespace std::string_view_literals;

int main()
{
    auto view = "test"sv;
    return 0;
}

Expected behavior

The sv literal to be found in string_view

Logs
cpptools/getCodeActions: file:///g%3A/Code/C%2B%2B/test.cpp (id: 22)
cpptools/getCodeActions: file:///g%3A/Code/C%2B%2B/test2.cpp (id: 23)
cpptools/activeDocumentChange: file:///g%3A/Code/C%2B%2B/test2.cpp
cpptools/textEditorSelectionChange
cpptools/getDocumentSymbols: file:///g%3A/Code/C%2B%2B/test2.cpp (id: 24)
cpptools/getDocumentSymbols
cpptools/textEditorSelectionChange
cpptools/getFoldingRanges: file:///g%3A/Code/C%2B%2B/test2.cpp (id: 25)
idle loop: reparsing the active document
Checking for syntax errors: file:///g%3A/Code/C%2B%2B/test2.cpp
Queueing IntelliSense update for files in translation unit of: G:\CODE\C++\TEST2.CPP
cpptools/finishUpdateSquiggles
Error squiggle count: 1
Update IntelliSense time (sec): 0.263

Screenshots
image

Additional context

Activity

  1. michelleangela commented on Jun 23, 2020

    @michelleangela
    Contributor

    Long Nguyen (@longnguyen2004)
    Could you provide the logs from running "C/C++: Log Diagnostics"? It could be that the files from the toolchain that you're using is not getting included in the include path for IntelliSense configuration (or c_cpp_properties.json). If they are not included, could you try adding the toolchain path to the includePath property?

  2. longnguyen2004 commented on Jun 24, 2020

    @longnguyen2004
    Author
    Log Diagnostics:
    -------- Diagnostics - 6/24/2020, 10:09:17 AM
    Version: 0.28.3
    Current Configuration:
    {
        "name": "llvm-mingw",
        "includePath": [
            "${workspaceFolder}/**"
        ],
        "defines": [
            "_DEBUG",
            "UNICODE",
            "_UNICODE"
        ],
        "compilerPath": "C:\\llvm-mingw\\bin\\clang++.exe",
        "cStandard": "c11",
        "cppStandard": "c++17",
        "intelliSenseMode": "clang-x64",
        "compilerArgs": [
            "-std=c++17"
        ],
        "browse": {
            "path": [
                "${workspaceFolder}/**"
            ],
            "limitSymbolsToIncludedHeaders": true
        }
    }
    Translation Unit Mappings:
    [ G:\Code\C++\test2.cpp ]:
        G:\CODE\C++\TEST2.CPP
    Translation Unit Configurations:
    [ G:\Code\C++\test2.cpp ]:
        Process ID: 7384
        Memory Usage: 14 MB
        Compiler Path: C:\llvm-mingw\bin\clang++.exe
        Includes:
            C:\LLVM-MINGW\INCLUDE\C++\V1
            C:\LLVM-MINGW\LIB\CLANG\10.0.0\INCLUDE
            C:\LLVM-MINGW\INCLUDE
        Defines:
            _DEBUG
            UNICODE
            _UNICODE
        Standard Version: c++17
        IntelliSense Mode: clang-x64
        Other Flags:
            --clang
            --clang_version=100000
    Total Memory Usage: 14 MB
    

    The correct include dir seems to be there, and VS Code do found the string_view file (confirmed by right-clicking and Go to Definition), the literal just doesn't get picked up.
    I also found this when I was looking through string_view, seems to be related to #1083 (comment)
    image

  3. sean-mcmanus commented on Jun 24, 2020

    @sean-mcmanus
    Contributor

    I don't think think we've ever tested (or have had user reports of) the llvm-mingw toolchain yet. You may want to try changing your IntelliSense mode to clang-x86.

  4. longnguyen2004 commented on Jun 25, 2020

    @longnguyen2004
    Author

    clang-x86 seems to work, although it's kinda a dirty hack imo, but I'm happy with it. You can close this now

  5. sean-mcmanus commented on Jun 25, 2020

    @sean-mcmanus
    Contributor

    I believe the fix for the "dirty hack" is #5258 (comment), i.e. to auto-detect the x86 IntelliSense mode based on the results from querying the compiler.

  6. locked and limited conversation to collaborators on Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions