473,326 Members | 2,175 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,326 software developers and data experts.

share a variable across two libraries

Hi,
I have to share a variable across two libraries. These libraries are
build separately and share a common header file.

I had tried this earlier using extern variable. That didn't help.

Any ideas about this ??

Thanks and Regards,
Jun 27 '08 #1
2 2268
guddu said:
Hi,
I have to share a variable across two libraries. These libraries are
build separately and share a common header file.

I had tried this earlier using extern variable. That didn't help.

Any ideas about this ??
If you must do this (rather than use parameter-passing, say), do it like
this:

/* commonheader.h */
#ifndef H_COMMONHEADER
#define H_COMMONHEADER 1
extern int shared_object; /* a declaration - include as appropriate */
/* + whatever else you feel appropriate in here */
#endif

/* firstlibsourcefile.c */
#include "commonheader.h"
int shared_object; /* ONE definition, here ONLY */
/* functions and stuff go here */

/* someotherlibsourcefile.c */
#include "commonheader.h" /* get the declaration */
/* Note the absence of a definition */
/* functions and stuff go here */

HTH. HAND.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #2
On Jun 24, 4:14 pm, guddu <visha...@gmail.comwrote:
Hi,
I have to share a variable across two libraries. These libraries are
build separately and share a common header file.

I had tried this earlier using extern variable. That didn't help.
How it didn't help?
Any ideas about this ??
If you want to share data, use parameters. Globals are not a good idea
except in very specific situations. Nevertheless, it works.
Jun 27 '08 #3

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

Similar topics

7
by: George Hester | last post by:
In one Application (2) the client is redirected to a Logon ASP in a different Application (1). A Session Variable is made in Application 2 which needs to be recognized in Application 1. Can I do...
0
by: TaeHo Yoo | last post by:
Hi all, We have three web based applications (A, B and C) and they are kept on different source safe database say SourceSafeA, SourceSafeB and SourceSafeC respectively. A solution contains aa...
5
by: Rich | last post by:
Hi there, For a quite big application, I need to get large amount of data within a static library (xxx.lib) and put them in a database (a class, say we call it CData), and then make it...
8
by: Tony Fonager | last post by:
I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application. (I have simplified my code, to make my project easier to...
2
by: Ahmed | last post by:
Dear All, I have three web applications that I want to provide one single web interface to all of them. If I am able to share the session between them, It will be great. so is this possibel?
11
by: Charles Law | last post by:
I have just been asked how to share functions and properties between two running applications. For example, I have App1 and App2 both running on the same machine. App1 uses a DLL (perhaps) that...
5
by: newjazzharmony | last post by:
I want to share one instance of an object across an ASP dot net application, and I'm trying to weigh the pros and cons of the following two approaches: a) Storing the object in ApplicationState...
3
by: Samuel R. Neff | last post by:
Is there any way to declare a static variable within a generic type definition and have that variable be shared across all constructed generic types? For example, how can I modify this code: ...
6
by: gara.matt | last post by:
Hi, I was wondering, I've been reading some C++ code written by others, usually libraries and stuff, and I've come across what strikes me as a distinctive style that pervades most of the code...
1
by: guddu | last post by:
Hi, I have to share a variable across two libraries. These libraries are build separately and share a common header file. I had tried this earlier using extern variable. That didn't help. Any...
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...
1
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: 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)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.