有没有办法传递 C++ 对象以与 Fortran 77 一起使用?例如:
C23456
program main
write (*,*) 'Hello from FORTRAN 77!'
call readstep('cube.stp'//CHAR(0),myshape)
stop
end
然后将 myshape 用作 C++ 对象,该对象将保存在 Fortran 使用的内存中,并将其传递给其他实际使用它的 C++ 函数?
编辑:这是 C++ 代码:
extern"C" {
void readstep_(char*,void*);
}
void readstep_(char* inputFile, void* outShape){
STEPControl_Reader reader;
reader = STEPControl_Reader();
int succeed = reader.ReadFile(inputFile);
if(!succeed){
std::cout << "There was an error with the input file" << std::endl;
return;
}
reader.NbRootsForTransfer();
reader.TransferRoots();
TopoDS_Shape myShape = reader.OneShape();
TopoDS_Shape* myShapePtr = new TopoDS_Shape();
(*myShapePtr) = myShape;
outShape = myShapePtr;
return;
}