各位:
两个进程间通过动态库的方式如何进行参数的传递?
我首先在一个库中做了如下的内容:
#include "caculate.h"
#include "stdio.h"
int iShare;
#pragma data_seg ("shareddate")
int iShareInSeg = 1;
#pragma data_seg
#pragma comment(linker, "/SECTION:shareddate,RWS")
int Getdata()
{
return iShareInSeg;
}
void SetData(int tmpData)
{
iShareInSeg = tmpData;
}
之后我会在其他的应用程序中,调用iShareInSeg这个参数,验证如下:
在test.c中做如下调用:
#include <stdio.h>
#include "caculate.h"
int iAdd;
int main()
{
iAdd = Getdata();
printf("get the return befor set : %d\n", iAdd);
SetData(100);
iAdd = Getdata();
printf("get the return : %d\n", iAdd);
return 0;
}
在编译后,发现每次执行./test,所打印的iShareInSeg值都不是续接上一次的。即每次都如下:
get the return befor set : 1
get the return : 100
在我的理解中,第二次执行的时候,不应该两次打印都是100吗???
求解答