关于在mac环境下配置sublime text3 C语言环境

本人MacOS系统版本为11.3.1, sublimeme text4

主要步骤参考  https://www.jianshu.com/p/45e49de3c894

然后不同处在于设置C.sublime-build中的代码不能按照https://www.jianshu.com/p/45e49de3c894文中的来配置,应该按如下配置:

按照网上新建Tools->Build System->New Build System.

新打开的文件下添加如下代码,并保存为C.sublime-build.

  1. "cmd": ["gcc", "${file}", "-o", "${file_path}/${file_base_name}"],
  2.   "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
  3.   "working_dir": "${file_path}",
  4.   "selector": "source.c",
  5.  
  6.   "variants":
  7.   [
  8.     {
  9.       "name": "Run",
  10.       "cmd": ["bash", "-c", "gcc '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
  11.     }
  12.   ]

这个是可用的。参考网址 http://blog.chinaunix.net/uid-27181185-id-4732728.html

而如下配置代码是不可用的(网上大多数搜出来的是这个,在我这是不可用的,而上面那样的可以用的)

"cmd" : ["gcc -o ${file_base_name} $file_name"],
"shell" : true,
"working_dir" : "$file_path",
"selector": "source.c",
"encoding":"utf-8",
"variants" :
[{
"name" : "Run",
"cmd" : "open -a terminal.app ./${file_base_name}"
}]

猜你喜欢

转载自blog.csdn.net/ferrarifomaul/article/details/117195929
今日推荐