473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

static variable in dynamic library?

Hi,

i have tried to understand how static variables work on a dynamic
library, but there's a point i can't see.

* Is the data segment (where static variables live, please confirm)
copied for every binary that is running linked to the library? This is
what it seems from my own experiments. That is, there is a copy of every
static variable for every binary linked. Then, is it really useful the
library?

* Is there a way to share a static variable between different binaries,
(without using threads, i mean)?

Thanks in advance,
-Eduardo

Nov 13 '05 #1
1 6928

Eduardo Suárez <eduardo_at_ctm.ulpgc.es> wrote in message
news:3f********@news.ll.iac.es...
Hi,

i have tried to understand how static variables work on a dynamic
library, but there's a point i can't see.

* Is the data segment (where static variables live, please confirm)
copied for every binary that is running linked to the library? This is
what it seems from my own experiments. That is, there is a copy of every
static variable for every binary linked. Then, is it really useful the
library?
Let's genuflect to the Topic Police first by saying that AFAIK, this is
off-topic for clc. Now that that's out of the way, yes it's "useful"
because the static variable is still shared by all the *callers* within the
program, and it's still hidden within the module, which is what static is
for. No, it's not shared by all the *binaries*. What you're looking for is
a kind of IPC (InterProcess Communication) which is sadly off-topic here
because the C spec is weak on IPC.

* Is there a way to share a static variable between different binaries,
(without using threads, i mean)?
You'll have to ask in a newsgroup specific to your platform. It sounds like
you're using Windows perhaps? IPC is one of the least satisfying elements
of Windows. I actually saw a job listing where they were looking for
somebody who was "familiar with all the methods for IPC on Windows" and I
was immediately struck with fear, loathing, and no desire to apply.

Thanks in advance,
-Eduardo


--$teve

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Grzegorz Dostatni | last post by:
I had an idea yesterday. (Yes, I know. Sorry). If we don't need to declare variables as having a certain type, why do we need to import modules into the program? Isn't the "import sys" redundant...
49
by: bearophileHUGS | last post by:
Adding Optional Static Typing to Python looks like a quite complex thing, but useful too: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 I have just a couple of notes: Boo...
28
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. ...
14
by: Shimon Sim | last post by:
I have a static variable defined something like this private static Dictionary<string, string> roles = new Dictionary<string,string>(); Can I safely assume that it will be live for the live of...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
7
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
20
by: JohnQ | last post by:
The way I understand the startup of a C++ program is: A.) The stuff that happens before the entry point. B.) The stuff that happens between the entry point and the calling of main(). C.)...
4
by: sealo | last post by:
Hello, I have a test in VS2005 that static library A.lib use the dynamic library C.dll. Then a application App use the A.lib. App-->A.lib-->C.dll It works. But if I remove the C.dll, the app...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.