Hi all,
I want to make a shared library which has a global variable.
This library is linked to two processes.
One main() function increments the global variable value
other main() function has to read the
incremented value.
How can I do this on gcc 4.0 , i-mac with OSX as 10.4.6. ?
When i make a shared library or dynamic library the global
variables are placed in local block of library, not
In the shared block of library.
Is their any way of coding to place my global variable in
shared block of library?
I have tried int nGlobalVariable _attrribute__((common)) = 2;
But this does not work. As every new executable has initial
value, not the value set by one of the process.
I do not want to use
shared memory like shmget, mmap or something. Actually
I want implementation of
#pragma
data_seg(“shared”)
Int nGlobal = 5;
#pragma data_seg()
on MAC OSX.
It works properly on vc if I place the above code in DLL..Different
copy of executable access the same memory.
I can set and get
nGlobal from different process.Same
implementation I want on MAC, is it possible?
Please help on this.
Thanks and Regards
Kumar
Gaurav