百科问答小站 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++ 的什么是 Java 不能取代的? 
  中国中央政府 2014 年采购为什么禁止设备预装 Windows 8 系统? 
  C/C++在函数调用时,为什么需要先将参数压栈? 
  微软小冰和小娜哪个更有可能统治世界? 
  如何评价轮子哥VCZH在微软十几年还是SDE2? 
  如何评价PC圈所谓「懂PC的都不买AMD」?真正懂PC的人都买了什么? 
  编程时怎么把函数当做变量使用? 
  如何用 C++ 从零编写 GUI? 
  为什么指针不能相加? 
  有哪些关于C++高性能服务器开发的高质量博客? 

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





© 2024-11-21 - tinynew.org. All Rights Reserved.
© 2024-11-21 - tinynew.org. 保留所有权利