Sublime Text C++ 构建系统 [英] Sublime Text C++ Build System

查看:46
本文介绍了Sublime Text C++ 构建系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下编译器设置来编译我的 C++ 代码:

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?

推荐答案

这个构建系统在我的机器上工作,基本上它是带有额外选项的默认 C++ 构建系统,

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}\""
        }
    ]
}

MacOs 可以放在 /Users/{user}/Library/Application Support/Sublime Text 3/Packages/User 目录下,C:\Users\{user}\Windows 中的 AppData\Roaming\Sublime Text 3\Packages\User 或 Linux 中的 ~/.config/sublime-text-3/Packages/User.
您可以将文件称为 C++17.sublime-build 之类的名称,以将其与默认构建系统区分开来.

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.

这篇关于Sublime Text C++ 构建系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆