传递向boost::process (boost::fusion)的参数向量

3
我正在尝试从一个字符串参数向量中创建一个boost::process对象:
void runProcess( const std::string& exe, const std::vector<std::string>& args )
{
    bp::ipstream out;
    bp::child c(exe, args, std_out > out);
    ...
}

看起来这个方法是可行的,但是我收到了以下警告:

警告 C4503:“boost::fusion::detail::for_each_linear”:装饰名称长度超过限制,名称已被截断

如果一个一个传递参数,bp::child c(exe, "param1", "param2", std_out > out);,则此警告会消失。

在这种情况下,调用child构造函数的正确方式是什么?


你使用得很正确。可能需要阅读这个链接:https://msdn.microsoft.com/zh-cn/library/074af4b6.aspx - StoryTeller - Unslander Monica
@StoryTeller:谢谢,但是我不清楚微软提供的示例如何帮助消除我的警告...那什么是“无警告语法”?(我有一个要求,即代码编译时不出现警告,并且我们总是更喜欢避免在本地禁用警告)。 - jpo38
1个回答

8
您需要按照预期使用它:
bp::child c(bp::search_path("ls"), bp::args({"-1", "-l"})/*, ...*/);

在你的情况下,可能像这样
void runProcess( const std::string& exe, const std::vector<std::string>& args )
{
    bp::ipstream out;
    bp::child c(exe, bp::args(args), std_out > out);
    ...
}

使用 bp::args 并不能阻止警告被报告。 - jpo38
哦。这些问题应该直接报告给库的开发人员。尝试使用 #include <boost/disable_warnings.hpp>,如果我没记错的话。 - sehe
1
完成:https://svn.boost.org/trac10/ticket/13323#ticket。感谢您的帮助。 - jpo38

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接