百科问答小站 logo
百科问答小站 font logo



gcc,clang,msvc等编译器有什么区别? 第1页

  

user avatar   mai-wen-xue-67 网友的相关建议: 
      

俺的了解十分肤浅。俺没啥文化, 初中毕业,大伙都知道。


但是 GCC 给俺的记忆十分深刻, 就是错误或者警告提示可以有彩色的。



######################################################################



VS CODE 不装插件怎么搞彩色的警告错误提示 COLORFUL WARNING


老实说, 俺也是在自己的另一台电脑上注意到有这个玩法。

还花了一个晚上阅读 VS CODE 的说明。

时间就是这样浪费掉的。

但是, 没找到任何有用的提示。


今天终于在寻找 GCC 的编译开关时发现了这个诀窍。

分享给大家。

"-fdiagnostics-color=always"

       -fdiagnostics-color=always   俺菜鸟, 所以也用上这个                 "-Wall",                 "-Wextra",     


当然, 很可能许多人知道, 但俺是第一次了解。



       "-fdiagnostics-color=always"    俺菜鸟, 所以也用上这个                 "-Wall",                 "-Wextra",     



TASKS.JSON

       {     "tasks": [         {             "type": "cppbuild",             "label": "C/C++: gcc build active file",             "command": "/usr/lib64/ccache/gcc",             "args": [                 "-lm",                 "-lpthread",                 "-lasound",                 "-g",                 "${file}",                 "-o",                 "${fileDirname}/${fileBasenameNoExtension}",                 "`pkg-config",                 "--cflags",                 "gtk+-3.0`",                 "`pkg-config",                 "--libs",                 "gtk+-3.0`",                 "-fdiagnostics-color=always"               ],             "options": {                 "cwd": "${workspaceFolder}"                              },             "problemMatcher": [                 "$gcc"                              ],             "group": {                 "kind": "build",                 "isDefault": true                              },             "presentation": {      "echo": true,      "reveal": "always",      "focus": false,      "panel": "new",      "showReuseMessage": true,     "clear": false     }                                 },          {    "type": "shell",    "label": "run",    "command": "/usr/lib64/ccache/gcc", //             "args": [                 "-lm",                 "-lpthread",                 "-lasound",                 "-g",                 "${file}",                 "-o",                 "${fileDirname}/${fileBasenameNoExtension}",                 "`pkg-config",                 "--cflags",                 "gtk+-3.0`",                 "`pkg-config",                 "--libs",                 "gtk+-3.0`",                 "-fdiagnostics-color=always"  // 彩色警告在这里弄             ],             "options": {                 "cwd": "${workspaceFolder}"                              },    "problemMatcher": [     "$gcc"    ],    "group": {     "kind": "test",      "isDefault": true    },    "presentation": {      "echo": true,      "reveal": "always",      "focus": false,      "panel": "new",      "showReuseMessage": true,     "clear": false     }      }                               ],      "version": "2.0.0" }     


*** 备注: WINDOWS 下 GCC 也有这个效果




//////////////////////////////////////////////////////////////////////


#####################################################################################################################################


TASKS.JSON (GCC WINDOWS)

       {  "version": "2.0.0",  "tasks": [   {    "type": "cppbuild",    "label": "C/C++: gcc.exe build active file",    "command": "C:\MinGW\bin\gcc.exe",    "args": [     "-lm",     "-g",     "${file}",     "-o",     "${fileDirname}\${fileBasenameNoExtension}.exe",     "-fdiagnostics-color=always"    ],    "options": {     "cwd": "C:\MinGW\bin"    },    "problemMatcher": [     "$gcc"    ],    "group": {     "kind": "build",     "isDefault": true    },    "detail": "compiler: C:\MinGW\bin\gcc.exe"   },   {    "type": "shell",    "label": "C/C++: gcc.exe build active file",    "command": "C:\MinGW\bin\gcc.exe",    "args": [     "-lm",     "-g",     "${file}",     "-o",     "${fileDirname}\${fileBasenameNoExtension}.exe",     "-fdiagnostics-color=always"    ],    "options": {     "cwd": "C:\MinGW\bin"    },    "problemMatcher": [     "$gcc"    ],    "group": "build",    "detail": "compiler: C:\MinGW\bin\gcc.exe"   }  ] }     


LAUNCH.JSON (WINDOWS)

*** 备注: 可能有错误, 但是能正常跑 HELLO WORLD

       {     // Use IntelliSense to learn about possible attributes.     // Hover to view descriptions of existing attributes.     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387     "version": "0.2.0",     "configurations": [         {             "name": "MY TESTING LAUNCH",             "type": "cppdbg",             "request": "launch",             "program": "${fileDirname}\${fileBasenameNoExtension}.exe",             "args": [],             "stopAtEntry": false,             "cwd": "C:\MinGW\bin",             "environment": [],             "MIMode": "gdb",             "miDebuggerPath": "C:\MinGW\bin\gdb.exe",             "setupCommands": [                 {                     "description": "Enable pretty-printing for gdb",                     "text": "-enable-pretty-printing",                     "ignoreFailures": true                 }             ],             "preLaunchTask": "C/C++: gcc.exe build active file"         }     ] }     


c_cpp_properties.json (WINDOWS)

       {     "configurations": [         {             "name": "Win32",             "includePath": [                 "${workspaceFolder}/**",                 "C:\MinGW\include"             ],             "defines": [                 "_DEBUG",                 "UNICODE",                 "_UNICODE"             ],             "windowsSdkVersion": "10.0.18362.0",             "compilerPath": "C:\MinGW\bin\gcc.exe",             "cStandard": "c11",             "cppStandard": "c++17",             "intelliSenseMode": "windows-gcc-x86"         }     ],     "version": 4 }     


##########################################################################



##########################################################################

另一台 WINDOWS 电脑上的配置文件 (能跑 HELLO WORLD)





TASKS.JSON


       {  "version": "2.0.0",  "tasks": [   {    "type": "cppbuild",    "label": "C/C++: gcc.exe build active file",    "command": "C:\msys64\mingw64\bin\gcc.exe",    "args": [     "-lm",     "-g",     "${file}",     "-o",     "${fileDirname}\${fileBasenameNoExtension}.exe",     //"`pkg-config", "--cflags", "gtk+-3.0`", "`pkg-config", "--libs", "gtk+-3.0`",     //"$(pkg-config --cflags gtk+-3.0)",                 "-Wall",                 "-Wextra",     "-fdiagnostics-color=always"    ],    "options": {     "cwd": "C:\msys64\mingw64\bin"    },    "problemMatcher": [     "$gcc"    ],    "group": {     "kind": "build",     "isDefault": true    },    "detail": "compiler: C:\msys64\mingw64\bin\gcc.exe"   },   {    "type": "shell",    "label": "C/C++: gcc.exe build active file",    "command": "C:\msys64\mingw64\bin\gcc.exe",    "args": [     "-lm",     "-g",     "${file}",     "-o",     "${fileDirname}\${fileBasenameNoExtension}.exe",     //"`pkg-config", "--cflags", "gtk+-3.0`", "`pkg-config", "--libs", "gtk+-3.0`",     //"$(pkg-config --cflags gtk+-3.0)",                 "-Wall",                 "-Wextra",                 "-fdiagnostics-color=always"    ],    "options": {     "cwd": "C:\msys64\mingw64\bin"    },    "problemMatcher": [     "$gcc"    ],    "group": "build",    "detail": "compiler: C:\msys64\mingw64\bin\gcc.exe"   }  ] }     


LAUNCH.JSON (WINDOWS)


       {     // Use IntelliSense to learn about possible attributes.     // Hover to view descriptions of existing attributes.     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387     "version": "0.2.0",     "configurations": [         {             "name": "MY TESTING LAUNCH",             "type": "cppdbg",             "request": "launch",             "program": "${fileDirname}\${fileBasenameNoExtension}.exe",             "args": [],             "stopAtEntry": false,             "cwd": "C:\msys64\mingw64\bin",             "environment": [],             "MIMode": "gdb",             "miDebuggerPath": "C:\msys64\mingw64\bin\gdb.exe",             "setupCommands": [                 {                     "description": "Enable pretty-printing for gdb",                     "text": "-enable-pretty-printing",                     "ignoreFailures": true                 }             ],             "preLaunchTask": "C/C++: gcc.exe build active file"         }     ] }     


c_cpp_properties.json (WINDOWS)


       {   "configurations": [       {           "name": "Win32",           "includePath": [               "${workspaceFolder}/**",               "C:\msys64\mingw64\include",               "C:\msys64\mingw64\lib\glib-2.0\include",               "C:\msys64\mingw64\include\gtk-3.0",               "C:\msys64\mingw64\include\glib-2.0",               "C:\msys64\mingw64\include\pango-1.0",               "C:\msys64\mingw64\include\harfbuzz",               "C:\msys64\mingw64\include\freetype2",               "C:\msys64\mingw64\include\libpng16",               "C:\msys64\mingw64\include\libpkgconf",               "C:\msys64\mingw64\include\fribidi",               "C:\msys64\mingw64\include\libxml2",               "C:\msys64\mingw64\include\cairo",               "C:\msys64\mingw64\include\pixman-1",               "C:\msys64\mingw64\include\gdk-pixbuf-2.0",               "C:\msys64\mingw64\include\gio-win32-2.0",               "C:\msys64\mingw64\include\atk-1.0",               "C:\msys64\mingw64\include\libgladeui-2.0"           ],           "defines": [               "_DEBUG",               "UNICODE",               "_UNICODE"           ],           "windowsSdkVersion": "10.0.18362.0",           "compilerPath": "C:\msys64\mingw64\bin\gcc.exe",           "cStandard": "c11",           "cppStandard": "c++17",           "intelliSenseMode": "windows-gcc-x86"       }   ],   "version": 4 }     



不用谢。


user avatar   pansz 网友的相关建议: 
      

这个问题透着一股邪乎味儿,怎么看怎么危险啊……

建议专业机构给予支援。




  

相关话题

  大型项目中面向过程思想 vs 面向对象思想,哪种开发效率更高? 
  为什么Google会在Android上推广使用64位应用,而微软却完全没有废弃32位应用的计划? 
  为什么很多人都说使用微软技术的公司是小公司?是不是微软的技术入门简单? 
  c/c++怎么把一个bool数组(刚好8个元素)转换成char? 
  让小娜怎么称呼我好? 
  windows如何监控文件的修改? 
  对容器类做改变的设计是否存在天生的错误? 
  微软当年是不是用并不比苹果好的技术战胜了苹果,为什么? 
  C 语言和 C++、C# 的区别在什么地方? 
  微软 (Microsoft) 应该砍掉 Bing 和 Xbox 吗? 

前一个讨论
老人听力不好不戴助听器会怎样?
下一个讨论
刚过完年手上有点压岁钱,不知该买游戏机还是买四大名著?





© 2024-09-19 - tinynew.org. All Rights Reserved.
© 2024-09-19 - tinynew.org. 保留所有权利