Sublime Text C++ Build System

不想你离开。 提交于 2021-02-10 14:57:37

问题


I use the following compiler settings to compile my C++ code:

g++ -Wall -Wextra -O2 -fwrapv -Wfloat-equal -Wconversion -std=c++17 A.cpp

But I am not sure how to setup the build system for the purpose, nor I want to try myself! I doubt that I may mess up the configuration (because I did once).

So I need help to configure my build system for the above compiler settings. How can I do that?


回答1:


This build system works in my machine, basically its the default C++ build system with the extra options,

{
    "shell_cmd": "g++ -Wall -Wextra -O2 -fwrapv -Wfloat-equal -Wconversion -std=c++17 \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c++",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ -Wall -Wextra -O2 -fwrapv -Wfloat-equal -Wconversion -std=c++17 \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\""
        }
    ]
}

You can place it in /Users/{user}/Library/Application Support/Sublime Text 3/Packages/User directory for MacOs, C:\Users\{user}\AppData\Roaming\Sublime Text 3\Packages\User in Windows or ~/.config/sublime-text-3/Packages/User in Linux.
You can call the file something like C++17.sublime-build to differentiate it from the default build system.



来源:https://stackoverflow.com/questions/62434508/sublime-text-c-build-system

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!