What does it mean that DLLs can't have Static writable data????

Login to reply to this topic.
Sat, 2006-04-08 06:31
Joined: 2006-04-08
Forum posts: 41
Hi,
I am new to Symbian.Plz Respond immediately if any body can help me.
Can anybody tell what does it mean that DLLs can't have static writable data??

Does it mean that:

class x
{
static TInt a;
public:
static void modify();
};

TInt x::a=5;

void x::modify()
{
a=10;
}

Does it mean that above written piece of code will not work if we have placed this whole piece of code in DLL??? i mean can't we modify static variable named a??
Thanx & Regards,
Amit Mahajan.

Sat, 2006-04-08 08:09
Joined: 2005-11-20
Forum posts: 1242
Re: What does it mean that DLLs can't have Static writable data?
Quote
Plz Respond immediately if any body can help me.

Please go immediately to Google, type "Symbian static data" and read   Smiley

René Brunner

Sat, 2006-04-08 16:44
Joined: 2004-11-29
Forum posts: 1232
Re: What does it mean that DLLs can't have Static writable data?
To answer your question; yes, you are correct. that code would not work in a symbian DLL.
The reason is an architectural design choice in how symbian dlls are implemented.
basicly, the dll code in ram is shared between all processes that use it. not loaded several times. Not allowing writeable static data simplifies the implementation, if you where to allow it, you had to allocate and keep track of a memory block for these variables for each process using th dll... a memory block that would have to be located at the same virtual memory address for each process useing them.. (since the code block should be the same for all) or really for each thread. And then it gets really messy.
Sat, 2006-04-08 19:42
Joined: 2005-11-20
Forum posts: 1242
Re: What does it mean that DLLs can't have Static writable data?
To which I like to add the following tricky bit: The VC++ compiler that I use for the emulator happily compiles code which causes writable static data without telling me anything. Only when I try to compile such code for the device - possibly only much later - it does not work.

See also this earlier post:
http://forum.newlc.com/index.php/topic,9526.0.html

René Brunner

Mon, 2006-04-10 12:23
Joined: 2006-04-08
Forum posts: 41
Re: What does it mean that DLLs can't have Static writable data?
Thanx To You, Allh and Rbrunner for responding.
what i have concluded is that there is no way out to use static data in DLLs, n whatever ways exists to use static writable data for example: Using TLS, they will be very expensive for my applications n i don't want that.
Thanx again.
  • Login to reply to this topic.