sublime text 3 完美实现gcc编译并运行

·
no tag February 12, 2017

1.首先,添加自定义buildsystem

打开 tools-> Build System -> New build system

添加自定义buildsystem

2.清空弹出的文件,将以下内容复制到文件中

{
    "cmd": ["gcc", "${file}", "-fexec-charset=gbk", "-std=c99", "-o", "${file_path}/${file_base_name}"],
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++",
    "encoding":"cp936",
    "variants":
    [
        {
            "name": "Build and Run",
            "cmd": ["cmd","/C","gcc", "${file}", "-fexec-charset=gbk", "-std=c99", "-o", "${file_path}/${file_base_name}","&start","cmd","/c", "${file_path}/${file_base_name}.exe &pause"]
        }
    ]
}

注意,本build方式默认以GBK方式编译(Compiler)以防止cmd乱码,使用c99标准

3. 按 ctrl + S 保存文件,文件名为 C

4. 打开一个 .c 文件,在 build system 中选择 c

5. 按 Ctrl + Shif + B 选择 build 方法。其中 c-build and run 为编译并运行,若不需要运行,选第一项c

6. 以后按 Ctrl + B 即可编译

  • 微笑
  • Windows 开启 Intel 快速开机技术, 完美解决GPT磁盘无法格式化为OS/2文件系统

_(:3 」∠)_
(抱歉)
这里不能评论哦

Title
打开 tools-> Build System -> New build system

© 2025 夏末阁. Using Typecho & Moricolor.

陕ICP备16018536号-1