How to edit Sublime Text build settings?

白昼怎懂夜的黑 提交于 2019-12-17 10:13:18

问题


I want to enable -std=gnu++11 in Sublime Text 3's C++ Single File build on Ubuntu 12.04.

I have already upgraded the tool chain to the latest g++ and do not want to see the following error on every build:

error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

I browsed to /home/myuname/.config/sublime-text-3 but cannot find any file to edit.

How can I edit the build settings?


回答1:


In Sublime Text 3, packages are wrapped up in .sublime-package zip archives. To access the C++ build file, first install Package Control (if you haven't already), then install the PackageResourceViewer plugin. Open the Command Palette (Under Tools tab), type prv to bring up the PackageResourceViewer options, select Open Resource, then navigate down to C++ and select the C++ Single File.sublime-build option. Edit it to your liking, save it, and you should be all set.

Below is a build system that should work on Linux. Hit CtrlB to build, and then hit CtrlShiftB to run the resulting program.

{
    "cmd": ["g++", "-std=gnu++11", "${file}", "-o", "${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["${file_path}/${file_base_name}"]
        }
    ]
}


来源:https://stackoverflow.com/questions/23789410/how-to-edit-sublime-text-build-settings

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