Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main( int argc, char ** argv )
  4. {
  5. puts("C99 Version:");
  6.  
  7. for( int i = 0; argv[i]; i++ ) {
  8. printf("%d: %sn", i, argv[i]);
  9. }
  10. getchar();
  11. return 0;
  12. }
  13.  
  14. C:UserspcDesktopCPPprojectc99.c:7:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
  15. for( int i = 0; argv[i]; i++ ) {
  16. ^
  17. C:UserspcDesktopCPPprojectc99.c:7:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
  18.  
  19. #include <iostream>
  20. #include <sstream>
  21. #include <vector>
  22. using namespace std;
  23.  
  24. int main( int argc, char ** argv ) {
  25.  
  26. stringstream version;
  27. version << "GCC version: "
  28. << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__
  29. << "nVersion string: " << __VERSION__;
  30.  
  31. cout << version.str() << endl;
  32.  
  33. vector<string> v = { "one", "two", "three" }; // C++11 feature - initializer list
  34.  
  35. for( string s : v ) { // C++11 feature - range-based for loop
  36. cout << s << endl;
  37. }
  38.  
  39. return 0;
  40. }
  41.  
  42. C:UserspcDesktopCPPprojectmain.cpp: In function 'int main(int, char**)':
  43. C:UserspcDesktopCPPprojectmain.cpp:17:45: error: in C++98 'v' must be initialized by constructor, not by '{...}'
  44. vector<string> v = { "one", "two", "three" }; // C++11 feature - initializer list
  45. ^
  46. C:UserspcDesktopCPPprojectmain.cpp:17:45: error: could not convert '{"one", "two", "three"}' from '<brace-enclosed initializer list>' to 'std::vector<std::basic_string<char> >'
  47. C:UserspcDesktopCPPprojectmain.cpp:19:18: error: range-based 'for' loops are not allowed in C++98 mode
  48. for( string s : v ) { // C++11 feature - range-based for loop
  49. ^
  50.  
  51. {
  52. "cmd": ["g++", "-std=c++11", "-o", "${file_path}/${file_base_name}", "${file}"],
  53. "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  54. "working_dir": "${file_path}",
  55. "selector": "source.c, source.c++",
  56.  
  57. "variants":
  58. [
  59. {
  60. "name": "Run",
  61. "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
  62. },
  63. {
  64. "name": "Build without C++11",
  65. "cmd": ["g++ '${file}' -o '${file_path}/${file_base_name}'"]
  66. }
  67. ]
  68. }
  69.  
  70. {
  71. "shell_cmd": "g++ -std=c++11 "${file}" -o "${file_path}/${file_base_name}"",
  72. "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  73. "working_dir": "${file_path}",
  74. "selector": "source.c, source.c++",
  75.  
  76. "variants":
  77. [
  78. {
  79. "name": "Run",
  80. "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
  81. },
  82. {
  83. "name": "Build without C++11",
  84. "cmd": ["g++ '${file}' -o '${file_path}/${file_base_name}'"]
  85. }
  86. ]
  87. }
  88.  
  89. {
  90. "cmd": ["g++", "-std=c++11", "-o", "${file_path}/${file_base_name}", "${file}"],
  91. "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  92. "working_dir": "${file_path}",
  93. "selector": "source.c, source.c++",
  94.  
  95. "variants":
  96. [
  97. {
  98. "name": "Run",
  99. "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
  100. },
  101. {
  102. "name": "Run with C++11",
  103. "cmd": ["bash", "-c", "g++ '${file}' -std=c++11 -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
  104. },
  105. {
  106. "name": "Build without C++11",
  107. "cmd": ["g++ '${file}' -o '${file_path}/${file_base_name}'"]
  108. }
  109. ]
  110. }
  111.  
  112. {
  113. "shell_cmd": "g++ -std=c++11 "${file}" -o "${file_path}/${file_base_name}"",
  114. "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  115. "working_dir": "${file_path}",
  116. "selector": "source.c, source.c++",
  117.  
  118. "variants":
  119. [
  120. {
  121. "name": "Run",
  122. "shell_cmd": "g++ -std=c++11 "${file}" -o "${file_path}/${file_base_name}" && "${file_path}/${file_base_name}""
  123. }
  124. ]
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement