为什么在DLL里面不能定义结构
当我在DLL中定义结构后总是报错,有什么帮法解决吗?
如果在 DLL中不能定义结构请解释一下~
[解决办法]
新建工程,新建代码,再试。
[解决办法]
//---------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
//---------------------------------------
// Important note about DLL memory management when your DLL uses the
// static version of the RunTime Library:
//
// If your DLL exports any functions that pass String objects (or structs/
// classes containing nested Strings) as parameter or function results,
// you will need to add the library MEMMGR.LIB to both the DLL project and
// any other projects that use the DLL. You will also need to use MEMMGR.LIB
// if any other projects which use the DLL will be performing new or delete
// operations on any non-TObject-derived classes which are exported from the
// DLL. Adding MEMMGR.LIB to your project will change the DLL and its calling
// EXE 's to use the BORLNDMM.DLL as their memory manager. In these cases,
// the file BORLNDMM.DLL should be deployed along with your DLL.
//
// To avoid using BORLNDMM.DLL, pass string information using "char * " or
// ShortString parameters.
//
// If your DLL uses the dynamic version of the RTL, you do not need to
// explicitly add MEMMGR.LIB as this will be done implicitly for you
//---------------------------------------
#pragma argsused
extern "C "_declspec(dllexport)
void CreateGraphAL(int rownum,int colnum);
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------
struct Gnode
{ //总是到这里就报错
int adjvex;
struct Gnode *nextarc;
};
struct VertexNode{
int vdata;
struct Gnode *Firstadj;
};
typedef VertexNode Adjlist[200];
struct LinkedWDigraph{
Adjlist head;
};
LinkedWDigraph *G;
void CreateGraphAL(int rownum,int colnum)
{
int n=0;
Gnode *s;
G=new LinkedWDigraph;
int dal[4]={-1,1,rownum,-rownum};
while(n <=rownum*colnum){
G-> head[n].vdata =n;
G-> head[n].Firstadj=NULL;
for (int i=0;i <4;i++){
s=new Gnode;
s-> adjvex =n+dal[i];
if(s-> adjvex> =0&&s-> adjvex <(rownum*colnum))
{
s-> nextarc =new Gnode;
s-> nextarc =G-> head[n].Firstadj;
G-> head[n].Firstadj =s;
}
}
n++;
}
}
编译通过