一块铌金属 2023-07-30 21:56 采纳率: 0%
浏览 24

Sublime Text + Clang 无法使用cin或cout

我的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]

  • 写回答

2条回答 默认 最新

  • 一块铌金属 2023-07-31 14:59
    关注

    放弃了用回g++了
    电脑重启过一次了,clang和sublime也重装了
    放弃了

    评论

报告相同问题?

问题事件

  • 创建了问题 7月30日

悬赏问题

  • ¥15 三分类机器学习模型可视化分析
  • ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
  • ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
  • ¥30 python,LLM 文本提炼
  • ¥15 关于将inet引入的相关问题
  • ¥15 关于一个倒计时的操作和显示设计
  • ¥15 提问STK的问题,哪位航天领域的同学会啊
  • ¥15 苹果系统的mac m1芯片的笔记本使用ce修改器使用不了
  • ¥15 单相逆变的电压电流双闭环中进行低通滤波PID算法改进
  • ¥15 关于#java#的问题,请各位专家解答!