[Fortran] 纯文本查看 复制代码
SUBROUTINE SUB(pc,n) Bind(C,Name="sub")
!DEC$ ATTRIBUTES DLLEXPORT::SUB
use , intrinsic :: ISO_C_Binding
integer , value :: n
type(c_ptr) , value :: pc
character(len=n) , pointer :: c
call c_f_pointer( pc , c )
write(*,*) c
END SUBROUTINE SUB
[C++] 纯文本查看 复制代码
#include "main.h"
#include <QLibrary>
extern "C" {
typedef void(*QTsub)(char*, int);
}
int main() {
QString a;
QLibrary dll("DLL2.dll");
if (dll.load()) {
QTsub sub = (QTsub)dll.resolve("sub");
a = "hello, World";
QByteArray ba = a.toLocal8Bit();
sub(ba.data(),ba.size());
}
}