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

Access variable using extern in a paricular file

Hi ALL,

My question is :

I have 3 files: f1.c f2.c and f3.c

I have declared variable int a; in f1.c and int a; in f2.c.

Now I want to use the variable int a; in f3.c . But this variable corresponds to the variable in f2.c . How to do this ????

Thanks
Sep 2 '13 #1
4 1283
in short, don't. do you have some particular problem you're trying to solve?
Sep 2 '13 #2
@ anonuser :

Yes, there is a problem. When I try to access the variable in f3.c, the compiler picks the value of variable from any of the two files f1.c or f2.c.
Sep 2 '13 #3
i realize that - my question is, why are you trying to have multiple copies of the variable by the same name? in general, it is bad practice to have variables outside function/class scope by DIFF names, let alone the same name. the linker can't distinguish between them.

what is the underlying reason you're doing this, please?
Sep 3 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ko Ko | last post by:
Dear All, I am wondering how to pass one variable from one php file to another continuously or discontinuously. For example, variable $a is declared in file1.php. I like to use that variable in...
2
by: Lu | last post by:
Hello, I am wondering how to protect a global variable in a header file from external access. So I googled and found: "The keyword 'static' has two different uses, depending on whether it is...
1
by: Pierre Maricq | last post by:
Hi, I am using Win2000 and Access2000. I need to build build a macro or write a VBA in Access that would screen all files contained in a directory on my C drive (files are structrured DAT...
14
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I...
1
by: sachin | last post by:
hi everyone, i am a beginer and wanted to know if i can access more than one xml file from one single xls file. if yes,then how will i be able to do it? thanks.
4
by: gaurav.dube | last post by:
I am facing a problem with warning removal I have got a header file it contains extern declarations of lot of variables (say 100) This header file is included in hundreds of .c files. Some of...
3
by: Praveen | last post by:
Hi, I would like to know is it possible not to use extern in a program. For eg I have the following programs file a.c contains a variable declaration as follows bool a = TRUE; I have...
4
by: sdanda | last post by:
I am new to this. I am working on vb.net windows applications.I created a Main form named as Form1. In this project i added some more windows forms. I would like to access the variable in main...
11
by: whirlwindkevin | last post by:
I saw a program source code in which a variable is defined in a header file and that header file is included in 2 different C files.When i compile and link the files no error is being thrown.How is...
2
by: zalek | last post by:
Hello, I wrote a program that is working OK which access DB2 using the following code: String w_conn = "jdbc:db2:DB2MAIN; Class.forName("COM.ibm.db2.jdbc.app.DB2Driver"); Connection db2Conn...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.