Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main( int argc, char ** argv )
- {
- puts("C99 Version:");
- for( int i = 0; argv[i]; i++ ) {
- printf("%d: %sn", i, argv[i]);
- }
- getchar();
- return 0;
- }
- C:UserspcDesktopCPPprojectc99.c:7:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
- for( int i = 0; argv[i]; i++ ) {
- ^
- C:UserspcDesktopCPPprojectc99.c:7:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
- #include <iostream>
- #include <sstream>
- #include <vector>
- using namespace std;
- int main( int argc, char ** argv ) {
- stringstream version;
- version << "GCC version: "
- << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__
- << "nVersion string: " << __VERSION__;
- cout << version.str() << endl;
- vector<string> v = { "one", "two", "three" }; // C++11 feature - initializer list
- for( string s : v ) { // C++11 feature - range-based for loop
- cout << s << endl;
- }
- return 0;
- }
- C:UserspcDesktopCPPprojectmain.cpp: In function 'int main(int, char**)':
- C:UserspcDesktopCPPprojectmain.cpp:17:45: error: in C++98 'v' must be initialized by constructor, not by '{...}'
- vector<string> v = { "one", "two", "three" }; // C++11 feature - initializer list
- ^
- C:UserspcDesktopCPPprojectmain.cpp:17:45: error: could not convert '{"one", "two", "three"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
- C:UserspcDesktopCPPprojectmain.cpp:19:18: error: range-based 'for' loops are not allowed in C++98 mode
- for( string s : v ) { // C++11 feature - range-based for loop
- ^
- {
- "cmd": ["g++", "-std=c++11", "-o", "${file_path}/${file_base_name}", "${file}"],
- "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
- "working_dir": "${file_path}",
- "selector": "source.c, source.c++",
- "variants":
- [
- {
- "name": "Run",
- "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
- },
- {
- "name": "Build without C++11",
- "cmd": ["g++ '${file}' -o '${file_path}/${file_base_name}'"]
- }
- ]
- }
- {
- "shell_cmd": "g++ -std=c++11 "${file}" -o "${file_path}/${file_base_name}"",
- "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
- "working_dir": "${file_path}",
- "selector": "source.c, source.c++",
- "variants":
- [
- {
- "name": "Run",
- "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
- },
- {
- "name": "Build without C++11",
- "cmd": ["g++ '${file}' -o '${file_path}/${file_base_name}'"]
- }
- ]
- }
- {
- "cmd": ["g++", "-std=c++11", "-o", "${file_path}/${file_base_name}", "${file}"],
- "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
- "working_dir": "${file_path}",
- "selector": "source.c, source.c++",
- "variants":
- [
- {
- "name": "Run",
- "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
- },
- {
- "name": "Run with C++11",
- "cmd": ["bash", "-c", "g++ '${file}' -std=c++11 -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
- },
- {
- "name": "Build without C++11",
- "cmd": ["g++ '${file}' -o '${file_path}/${file_base_name}'"]
- }
- ]
- }
- {
- "shell_cmd": "g++ -std=c++11 "${file}" -o "${file_path}/${file_base_name}"",
- "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
- "working_dir": "${file_path}",
- "selector": "source.c, source.c++",
- "variants":
- [
- {
- "name": "Run",
- "shell_cmd": "g++ -std=c++11 "${file}" -o "${file_path}/${file_base_name}" && "${file_path}/${file_base_name}""
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement