J
jyniu
Unregistered / Unconfirmed
GUEST, unregistred user!
关于<a href="DispQ.asp?LID=352159">在Delphi中如何调用C++动态链接库中输出的类</a>
提到的类:
#ifndef __SIMPLY_INC__
#define __SIMPLY_INC__
#ifdef __EXPORTS__
#define CLASS_IMPL __declspec( dllexport )
#else
#define CLASS_IMPL
#endif
class CLASS_IMPL HelloWorld {
public:
virtual void __cdecl setMessage( char *msg );
virtual int __cdecl getMessageLen( void );
virtual void __cdecl sayHello( void );
virtual void __cdecl sayHello( char *msg );
virtual void __cdecl free( void );
};
extern "C" HelloWorld * __cdecl GetHelloWorld( void );
#endif //__SIMPLY_INC__
使用Delphi实现的话,下面的代码即可正常运行
HelloWorld = class(TObject)
public
procedure setMessage( msgchar );
virtual;
cdecl;
abstract;
function getMessageLen:Integer;
virtual;
cdecl;
abstract;
procedure sayHello( msgchar );
overload;
virtual;
cdecl;
abstract;
procedure sayHello;
overload;
virtual;
cdecl;
abstract;
procedure free;
virtual;
cdecl;
abstract;
end;
function GetHelloWorld:HelloWorld;
cdecl;
external 'simply.dll' name 'GetHelloWorld';
但细心者会发现两个overload的方法sayHello的声明顺序是反的。
怎样使两者的顺序一致,我尝试着调整了可能的C++/Pascal的编译参数,
均未能成功。
那位高手能指点迷津!!!
提到的类:
#ifndef __SIMPLY_INC__
#define __SIMPLY_INC__
#ifdef __EXPORTS__
#define CLASS_IMPL __declspec( dllexport )
#else
#define CLASS_IMPL
#endif
class CLASS_IMPL HelloWorld {
public:
virtual void __cdecl setMessage( char *msg );
virtual int __cdecl getMessageLen( void );
virtual void __cdecl sayHello( void );
virtual void __cdecl sayHello( char *msg );
virtual void __cdecl free( void );
};
extern "C" HelloWorld * __cdecl GetHelloWorld( void );
#endif //__SIMPLY_INC__
使用Delphi实现的话,下面的代码即可正常运行
HelloWorld = class(TObject)
public
procedure setMessage( msgchar );
virtual;
cdecl;
abstract;
function getMessageLen:Integer;
virtual;
cdecl;
abstract;
procedure sayHello( msgchar );
overload;
virtual;
cdecl;
abstract;
procedure sayHello;
overload;
virtual;
cdecl;
abstract;
procedure free;
virtual;
cdecl;
abstract;
end;
function GetHelloWorld:HelloWorld;
cdecl;
external 'simply.dll' name 'GetHelloWorld';
但细心者会发现两个overload的方法sayHello的声明顺序是反的。
怎样使两者的顺序一致,我尝试着调整了可能的C++/Pascal的编译参数,
均未能成功。
那位高手能指点迷津!!!