百科问答小站 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 网友的相关建议: 
      

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

建议专业机构给予支援。




  

相关话题

  C++ 类当中为什么要有private? 
  VS2010编x64程序和编x86程序用的是同一套lib? 
  如果编译器遇到未定义行为把硬盘格式化了,需要负法律责任吗? 
  const TYPE * 究竟限制的是什么? 
  C语言 下面哪个定义是合法的? 
  如何看待10月6号微软发布的Lumia950/950XL的外观设计? 
  学生应该如何充分利用 PC? 
  如何看待微软员工称谷歌利用不正当手段对Edge造成了破坏? 
  如何看待收购动视暴雪成微软史上最大收购,微软真正看中的是什么? 
  Windows 10 Mobile正式版的体验将会怎样? 

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





© 2024-05-18 - tinynew.org. All Rights Reserved.
© 2024-05-18 - tinynew.org. 保留所有权利