Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Memory for extern variable

Status
Not open for further replies.

M.RAMARAO

Newbie level 3
Joined
Nov 13, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
16
if we declare a variable as external(with "extern" keyword) where the memory will be allocated for this variable? or it will be allocated or not?
can anyone give me the clarification about this please..............
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,421
Helped
14,442
Reputation
29,148
Reaction score
13,239
Trophy points
1,393
Location
Bochum, Germany
Activity points
284,394
An external declaration is a reference to an otherwhere globally defined variable.

Without the definition, no storage is allocated and an "undefined object" error asserted.
 

Joined
Dec 4, 2012
Messages
4,294
Helped
822
Reputation
1,654
Reaction score
793
Trophy points
1,393
Location
Bangalore, India
Activity points
0
All your program if it is a single file or spanned into multiple files gets compiled into one .hex file which is burned to the microcontroller. So, all your program will use the same ROM and RAM in the micro. Declaring a variable or function as extern is related only for the Compiler. If the Compiler encounters extern when Compiling then it know that the variable or function is in some other file. If the extern variable is a global variable then space will be allocated for it, if it is a non global variable then it gets created when the particular function is called.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top