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

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

建议专业机构给予支援。




  

相关话题

  将文件编译成某种代码,打印到A4纸上,这种想法是否可行? 
  汇编下call和ret指令是否有内存屏障的作用? 
  C++ 有类似C语言container_of这种,通过指针访问对象的方法么? 
  如何评价 2019 年 10 月 2 日微软新发布的搭载安卓系统的双屏手机 Surface Duo? 
  如何评价微软2016年3月18日Windows 10 Mobile推送放弃绝大多数旧机型的决定? 
  微软小冰测颜值是否比较准?为什么? 
  很多人说 C++ 的 MFC 已经过时了,那新入门的人到底应该学什么? 
  C语言能判断一个变量是int还是float吗? 
  为什么说 goto 是一种不好的用法? 
  C++整型有__int8、__int16、__int32等等,为什么还要short、int、long? 

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





© 2024-12-22 - tinynew.org. All Rights Reserved.
© 2024-12-22 - tinynew.org. 保留所有权利