我有一些现有的代码,我尝试使用clang 3.3和libC++从llvm.org进行编译。一个简单的步骤来检索另一个命令的结果。看来,std :: filebuf不再提供FILE *构造函数,并且我试图替换代码的所有想法都未能打开该命令,即fb.is_open()始终返回false。将std :: filebuf(FILE *)转换为使用libC++
从我能找到的,我将不得不使用像fb.open(cppcommand.c_str(), std::ios::in);
而不是popen。
代码的主要部分是: -
std::string cppcommand = "/usr/bin/cpp -xc -nostdinc test.c";
FILE *cpppipe = popen (cppcommand.c_str(), "r");
std::filebuf fb (cpppipe);
if (! cpppipe || ! fb.is_open()) {
std::cerr << "Could not run '" << cppcommand.c_str() << "'\n";
return false;
} else {
std::istream in (&fb);
std::ostringstream ss;
ss << in.rdbuf();
result = ss.str();
}
我怎样才能得到这与libc的运行++?
代码是从OpenShadingLanguage,我试图让它在FreeBSD 10.0 Beta1下编译,其中包含在从基本安装中删除gcc和libstdC++之后的clang 3.3和libC++。
如果手动粘贴到终端中,正在使用的cppcommand字符串将无误地运行。