我的Sublime Text已经使用了一段时间了,安装了LSP和Terminus插件,我一开始还是能正常使用cin和cout,但是不知道我不小心干了什么cin和cout失效了,只要到了有cin或cout的部分程序就停滞了。printf和scanf倒是能正常使用。当我使用Sublime自带的C++编译代码的时候是可以使用cin和cout的。
我使用的配置代码如下
{
// Windows
// build only
"shell_cmd": "clang++ -std=c++11 -g -Wall ${file} -o ${file_path}/../bin/${file_base_name}",
// check the file name using regex
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
// set the encoding to utf-8
"encoding": "utf-8",
// doesn't matter if I use full path
"working_dir": "${file_path}",
// only C and Cpp files can use this sublime-build file
"selector": "source.c, source.c++",
"variants": [
{
// build and run in Terminus (sublime plugin)
// [Recommanded]
"name": "Run In Terminus",
"target": "terminus_exec",
"cancel": "terminus_cancel_build",
"shell_cmd": "clang++ -std=c++11 -g -Wall \"${file}\" -o \"${file_path}/../bin/${file_base_name}\" && cmd /c \"${file_path}/../bin/${file_base_name}\""
},
{
// build and run in CMD
// you can type something in CMD then your progam can get its inputs
// [Recommanded]
"name": "Run in CMD",
"shell_cmd": "clang++ -std=c++11 -g -Wall \"${file}\" -o \"${file_path}/../bin/${file_base_name}\" && start cmd /c \"\"${file_path}/../bin/${file_base_name}\" & pause \""
},
{
// build and run in sublime
// but you can't input anything to your progam
"name": "Run in Sublime",
"shell_cmd": "clang++ -std=c++11 -g -Wall \"${file}\" -o \"${file_path}/../bin/${file_base_name}\" && cmd /c \"${file_path}/../bin/${file_base_name}\""
}
]
}
我的测试代码如下
#include <iostream>
using namespace std;
int main() {
cout << "Hello World\n";
return 0;
}
输出如下
[Finished in 2.86s with exit code 3221225477]
放弃了用回g++了
电脑重启过一次了,clang和sublime也重装了
放弃了
艹
后缀名是cpp还是c