重新编译我们的FORTRAN代码并在C++中使用后,我们的system()或C_str()命令无法正常工作

After recompiling our FORTRAN-code and using it in C++ our system() or c_str() command don`t work properly

本文关键字:我们 str system 命令 工作 常工作 FORTRAN 代码 编译 新编译 C++      更新时间:2023-10-16

嗨,我有一个大问题:我们在几年前用C++/Qt 4.8.4/Qt Creator 2.8.1创建了一个程序,在执行时运行另一个可执行文件(用FORTRAN编写和编译(。一切都很顺利。

我们用Visual studio的新版本重新编译了Fortran代码,但现在它突然不起作用了。我查看了我的C++代码,发现了程序崩溃的位置:

std::string Executable = ApplicationName.toStdString();
bool RunOK=  system((Executable+" > "+"X.out2").c_str());
QString  ExeName =  (Executable+" > "+"X.out2").c_str();
QString tf = QString::number(qweee);
if(system((Executable+" > "+"X.out2").c_str()))
{
msg.showMessage("msg.showMessage("An XXX error occured during calculation......((Executable+ > +X.out2).c_str(): "+ExeName +"......(system((Executable+ > +X.out2).c_str()): "+ QString::number(RunOK));
if(QFile(OutputFiles[0]).exists())
QFile(OutputFiles[0]).remove();
}

不知怎的,系统((Executable+">"+"X.out2"(.c_str(((变成了true,这在以前是没有发生过的。

这似乎发生在c_str-命令或system((-命令中。

我们以前遇到过一些缺少dll的问题这是另一个dll问题吗?如果是,是哪个

有人能帮我们吗

谢谢

system的返回值是一个整数,而不是布尔值。它的值只针对一个非常特殊的情况定义,即system(nullptr)。这里的情况并非如此。因此,你得到的结果是零还是非零取决于你的特定C++实现,它确实发生了变化。("新视觉工作室版本"(。您不能依赖非零均值错误

c_str()根本不是嫌疑犯。