Skip to content

IntelliSense not working with __VA_OPT__ #4088

@Bemteb

Description

@Bemteb

Type: LanguageService

Describe the bug

  • OS and Version: Linux Mint 18.2
  • VS Code Version: 1.37.0
  • C/C++ Extension Version: 0.25.0
  • Other extensions you installed (and if the issue persists after disabling them): austin.code-gnu-global; disabling it doesn't change anything
  • A clear and concise description of what the bug is.

I get an error message when using __VA_OPT__ in my program, as IntelliSense expects a closing bracket at the wrong place.
The exact error message is "expected a ')'".
Below are a minimal example of the problem and also my c_cpp_properties.json file.

#include <experimental/source_location>
#include <string>

template<typename... Args>
void make_error(const std::experimental::fundamentals_v2::source_location& location, std::string message, Args... args)
{
    // does some stuff to make a fancy error message, including location of the error

};

#define ERROR(msg, ...) make_error(std::experimental::fundamentals_v2::source_location::current(), msg __VA_OPT__(,) __VA_ARGS__)

int main()
{
    ERROR("This is an error without any arguments.");

    int i = 3;
    double j = 3.5;
    ERROR("This is an error telling us that i = % and j = %.",i,j);
}
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++20",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

If I replace __VA_OPT__(,) by just a , the problem no longer occurs. But in this case, the first of the two error messages is wrong of course, both in vs code and when compiling, as it then misses arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature RequestLanguage ServiceVisual StudioInherited from Visual StudiofixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions