tags:

views:

274

answers:

1

Hi, I try to declare a shared data segment in a DLL. I declare the area with:

#pragma data_seg(".shared")
int varx=0; 
#pragma data_seg()
__declspec(allocate(".shared")) 
// I found this declspec suggestion in another forum
#pragma comment (linker,"/section:.shared,RWS")

Also I add

SECTIONS
      .shared READ WRITE SHARED

into the def file. However I always get:

LINK : warning LNK4039: section '.shared' specified with /SECTION option does not exist

error. If I do only one (.def or pragma comment) get only one, if do both get two errors.

Anything I miss?

+1  A: 

Ive only seen that declspec used in this way:

 __declspec(allocate(".shared")) int varx=0;

I would try writting only this:

#pragma comment (linker,"/section:.shared,RWS")

 __declspec(allocate(".shared")) int varx=0;

avoiding declaring an empty section or a multiply defined one

ChaosCoder
argh! without allocating the space, allocating the contained variable was so unwise
paul simmons