Ofer Elboher

Hi,

I added the following code in a DLL of mine:

#pragma data_seg(".shared")
BOOL my_flag = false;
#pragma data_seg()
#pragma comment(linker, "/section:.shared,RWS")

But after some user application calls a function that sets it to 'true', it still shows up 'false' to the instance of this DLL in another user application.

Any help would be appreciated.

Thanks,
Ofer.




Re: Visual C++ General Sharing a Flag Between Users of Same DLL

Viorel.

Can you retry with volatile keyword and see if helps

volatile BOOL my_flag = false;





Re: Visual C++ General Sharing a Flag Between Users of Same DLL

Ofer Elboher

I already tried, and it does not help.

Any other idea

Thanks,

ofer.






Re: Visual C++ General Sharing a Flag Between Users of Same DLL

Ofer Elboher

One more thing that might matter: The 2 user applications that load this DLL are an unmanaged C++ app and a managed C# app.

Ofer.






Re: Visual C++ General Sharing a Flag Between Users of Same DLL

Paul Marriott

Have you got any other variables declared in the data_seg area

I have found that all vars need to be initialised, and if any or then are not then the whole data_seg fails

i.e - Fails

#pragma data_seg(".shared")
BOOL my_flag = false;

BOOL md_data;
#pragma data_seg()

i.e OK

#pragma data_seg(".shared")
BOOL my_flag = false;

BOOL md_data = false
#pragma data_seg()





Re: Visual C++ General Sharing a Flag Between Users of Same DLL

Ofer Elboher

No, I only have a single boolean there.

Ofer.