tags:

views:

40

answers:

1

When I trace one open source, I saw someone has the following code

#prama data_seg(".XXXX")
static char *test=NULL;
FILE *f1;
#prama data_seg()

However, even after checking http://msdn.microsoft.com/en-us/library/thfhx4st(VS.80).aspx, I still not sure why we need to do so, can someone help me to understand this part?

thank you

A: 

This is usually done to share the data that's designated to be in that segment. The code you have above will normally go in a DLL. You also use a .def file that specifies that the ".XXXX" segment is going to have the "SHARED" attribute.

When you do all that, the data in that segment gets shared between all the processes that load the DLL, so those variables are shared between all those processes.

Jerry Coffin