Sublime Text 3用于OS X的C ++构建系统 [英] Sublime Text 3 C++ Build System for OS X

查看:193
本文介绍了Sublime Text 3用于OS X的C ++构建系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OS X(Mountain Lion)中使用Sublime Text 3。我试图在Sublime Text 3中构建和运行一个简单的hello world应用程序。它工作正常,但是当我采取任何输入,它不提示任何控制台输入。



这是我的构建配置文件:

  {
cmd:[g ++,$ {file},-o,$ {file_path} / $ {file_base_name}, file_regex:^(.. [^:] *):([0-9] +):?([0-9] +)?:? :$ {file_path},
selector:source.c,source.c ++,

variants:
[
{
name:Run,
cmd:[bash,-c,g ++'$ {file}'-o'$ {file_path} / $ {file_base_name}'& ;&'$ {file_path} / $ {file_base_name}']
}
]
}

示例程序:

  #include< iostream> 

using namespace std;

int main(){
int number;

cout<< 输入数字:;
cin>>数;
cout<< 您输入:<<数;

return 0;
}


解决方案

https://www.sublimetext.com/forum/viewtopic.php?f=2&t=5219 =nofollow>此主题,ST根本不允许交互式构建。 p>

编辑



检查此主题在这里找到解决方法。


I am using Sublime Text 3 in OS X (Mountain Lion). I am trying to build and run a simple hello world application in Sublime Text 3. It's working fine, but when I am taking any input, it's not prompting for any console input. It just directly runs and shows output without taking any input.

Here's my build profile:

{
    "cmd": ["g++", "${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++ '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
        }
    ]
}

Sample program:

#include <iostream>

using namespace std;

int main() {
    int number;

    cout << "Enter number: ";
    cin >> number;
    cout << "You entered: " << number;

    return 0;
}

解决方案

According to this thread, ST simply doesn't allow for interactive builds.

Edit:

Check out this thread here for a workaround.

这篇关于Sublime Text 3用于OS X的C ++构建系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆