美文网首页
12. Mac OS Sublime Text 3 C/C++

12. Mac OS Sublime Text 3 C/C++

作者: MiracleJQ | 来源:发表于2019-10-10 11:45 被阅读0次

    Tools -> Build System -> New Build System 新建编译系统。在新打开的窗口中替换为以下代码:

    {
        "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && osascript -e 'tell application \"Terminal\" to activate do script \"clear&&${file_path}/${file_base_name} && read -p \\\"Press Enter to exit.\\\"&&exit\"'"],
        "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
        "working_dir": "${file_path}",
        "selector": "source.c, source.c++",
        "variants":
        [
            {
                "name": "Run",
                "cmd": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
            }
        ]
    }
    

    Command + s 保存,命名为MyC++
    Tools -> Build System选中MyC++
    Command + Shift + B编译,选MyC++(不加Run的那个)。

    或者

    {
        "cmd": ["g++", "${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": ["bash", "-c", "g++ '${file}' -o '${file_path}/${file_base_name}' && open -a Terminal.app '${file_path}/${file_base_name}'"]
            }
        ]
    }
    

    相关文章

      网友评论

          本文标题:12. Mac OS Sublime Text 3 C/C++

          本文链接:https://www.haomeiwen.com/subject/oyhvyctx.html