macos - 为什么mac上C++编译不提示错误?
高洛峰
高洛峰 2017-04-17 13:22:02
0
2
478
  1. 我在mac上使用sublime text编译c++程序,当程序有错时,编译器会完全没有提示。请问该如何获得提示?
    比如:我在第二个printf中故意输错result,cmd+B编译后,完全没有反应,也不提示。


如果输入正确,结果如下:

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
巴扎黑

Your sublimetext build system is not set up properly

Click Tools->Build System-> new Build system, copy the code below and save it. The name will be c++11. Then you can select the c++ you just created in the build system. +11.

PS: This script will not only compile but also run automatically

{
 "cmd": ["g++", "-std=c++0x", "${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++ -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
   }
 ]
}
阿神

General method:

  1. Install Xcode

  2. Open Terminal

  3. cd to the directory where cpp is located

  4. Input clang++ name.cpp Compile

  5. Enter ./a.out to run

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template