Boost有一个跨平台的exec吗? [英] Is there a cross-platform exec in Boost?

查看:147
本文介绍了Boost有一个跨平台的exec吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C ++中执行一个子进程。我需要它在Windows和Linux上工作。
Boost中是否有这样的函数?
这样做的标准方式是什么?

I want to execute a sub-process in C++. I need it to work on Windows and Linux. Is there such a function in Boost? What is the standard way of doing it?

推荐答案

Poco ACE 有过程类,它做你想要的。参见Foundation-> Processes-> Process in Poco; Process.h / Process.cpp为Ace。如果 QT 有类似的情况,我不会感到惊讶。

Poco and ACE have Process classes that do what you want. See Foundation->Processes->Process in Poco; Process.h/Process.cpp for Ace. I wouldn't be surprised if QT has something similar.

至于如何做,基本上你包装操作系统依赖和埋葬的细节。 Poco和Ace提供了对比常见的方法。 Poco倾向于通过为每个平台编写实现对象(xxx_impl)来处理事务,并根据操作系统提取适当的对象。 ACE似乎#ifdef的代码,有时到疯狂的点,虽然在公平,自从我看了那段代码已经很长时间了。

As for how to do it, basically you wrap the OS dependencies and bury the details. Poco and Ace offer contrasting common methods. Poco tends to handle things by writing implementation objects (xxx_impl) for each platform with the proper one getting pulled in depending on the OS. ACE seems to #ifdef the code, sometimes to the point of madness, though in fairness it has been a long time since I looked at that code.

这篇关于Boost有一个跨平台的exec吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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