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

Restricting the access of a Global variable

Hi,
I am facing some some problem in restricting the access of a
variable....
My question is described below.....

Let I have two different C source files 'a.c' and 'b.c'.

In the file 'a.c' there is a global variable declared 'int
GlobalVariable' and the same variable is extern in the file 'b.c'.

a.c b.c
----------------------- ---------------------------
|int Globalvariable; | |extern int Globalvariable;
|int main() | |
|{ | |Other funtions
|...... | |{
|} | |......
| | |}
|---------------------- ----------------------------

Now I want to restrict the access of that variable "Globalvariable" in
the file 'b.c' without using any semaphore.

Thanks and Regards,
Tarun Sant

Jan 17 '08 #1
2 1999

<sa********@gmail.comwrote in message Hi,
I am facing some some problem in restricting the access of a
variable....
My question is described below.....

Let I have two different C source files 'a.c' and 'b.c'.

In the file 'a.c' there is a global variable declared 'int
GlobalVariable' and the same variable is extern in the file 'b.c'.
/*
b.c
*/
static int globalVar = 2;

/*
a.c
*/
int globalVar = 3;

/*
a.h
*/
extern int globalVar;

Now anything that includes a.h can access its version of gloablVar, whilst
the version in b.c is safely locked away.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jan 17 '08 #2
sa********@gmail.com wrote:
Hi,
I am facing some some problem in restricting the access of a
variable....
My question is described below.....

Let I have two different C source files 'a.c' and 'b.c'.

In the file 'a.c' there is a global variable declared 'int
GlobalVariable' and the same variable is extern in the file 'b.c'.

a.c b.c
----------------------- ---------------------------
|int Globalvariable; | |extern int Globalvariable;
|int main() | |
|{ | |Other funtions
|...... | |{
|} | |......
| | |}
|---------------------- ----------------------------

Now I want to restrict the access of that variable "Globalvariable" in
the file 'b.c' without using any semaphore.
What do you mean by "restrict the access"? Be more precise and we may be
able to help.

As you are talking about semaphores, are you implying you want to
enforce some form of serialization of access (perhaps by multiple
threads)?
Jan 17 '08 #3

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

Similar topics

3
by: amywolfie | last post by:
Hi all: I develop in both FileMaker Pro and Access. FileMaker has a global field type, whereby the value of the gfield is the same for all records. Is there an equivalent in MS Access...
3
by: Jorge Cecílio | last post by:
Hi! I would like to export some MS-Access reports output to pdf. However, the only possibility offered by Access (afaik) for me to export formatted output is snp (snapshot) (I use MS-Office...
6
by: Mr Newbie | last post by:
Hi, Im in a situation where I need to restrict users, but I dont have access or wont be allowed access to manage groups in the domain. How can I restrict access is this case ? -- Best...
1
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the...
26
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null);...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
4
by: RgeeK | last post by:
I have a main module doStuff.py and another module utility.py. At the start of doStuff.py I call import utility.py Then I also proceed to initiallize some global variables sName = "" ...
6
by: provor | last post by:
Hello, I have the following code that I am using when a user presses a button to import an excel file into a table. The code is hard coded to point to the correct table. This works great for this...
7
by: shashi shekhar singh | last post by:
Respected Sir, I am really tired in solving of this issue that have been arises when i would like to restrict files to access only on my Test page , here i am retriving my files in iframe in Test...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.