I am in the process of learning c++ and I'm using visual studio code for Mac. I use Code Runner to run my program. My problem is that when I use something from c++11 like "auto" for variable declaration, visual studio code gives me a warning like this, but if I try running it on Xcode or Eclipse it doesn't:
warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for(auto y: nstrVec)
This is the program if it's necessary:
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <numeric>
#include <sstream>
int main(){
std::vector<std::string> nstrVec(10);
std::string str("I'm a string");
nstrVec[0] = str;
std::cout << str.at(0) << "\n";
std::cout << str.front() << " " << str.back() << "\n";
std::cout << "Length " << str.length() << "\n";
// copies all characters after the fourth
std::string str2(str, 4);
for(auto y: nstrVec)
if(y != "")
std::cout << y << "\n";
return 0;
}
And this is the c_cpp_proprerties.json file:
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/System/Library/Frameworks/Kernel.framework/Versions/A/Headers"
],
"defines": [],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
Views and more Actions click Disable All Installed Extensions then Enable All Extensions . Restart VSCode and it should be done; -) You can make sure again that the extensions are enabled.. Good Luck !
Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration. Find and check the box Run in Terminal.
They can contain malware, yes. When you download and run an extension, you are trusting it to do pretty much anything it wants with the permissions of your user. VS Code does not implement sandboxing (like browsers do), and the code is not much restricted.
In VS Code:
File>>Preference>>Settings>>Extensions
find C_Cpp>Default:Cpp Standard drop down menu
set that to c++11
I had the same problem, but solved it using set vscode-user-settings <>
"clang.cxxflags": ["-std=c++14"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With