Reputation: 938
I am writing a simple structure in using vscode in c++
#include <variant>
using namespace std;
struct Entry {
string name;
variant<double,int> v;
};
I am using the C/C++ extension by Microsoft.
Despite the fact that it's compiling just fine, somehow the extension is unable to detect the variant
class.
How do I fix this issue with VScode?
Upvotes: 1
Views: 2879
Reputation: 663
If you are using the clangd extension (not the C++ one by Microsoft), add this in your .vscode/settings.json
file:
{
"clangd.fallbackFlags": [
"-std=c++17"
]
}
Then reload the extesion to apply the changes.
Upvotes: 1
Reputation: 81
For those who use cl.exe
(VSCode guide on configuring Microsoft C++) to compile and link C/C++ program:
.vscode/task.json
."/std:c++latest"
to args
list.Ctrl + Shift + B
to build.More options regarding cl.exe
can be found by typing cl.exe /help
in Developer Command Prompt for VS XXXX
.
Upvotes: 0
Reputation: 938
Found it!
The Same goes for this kind of problems in C.
It seems like the default c++ standard of this extension can sometimes be insufficient.
Upvotes: 6