Continue to Site

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.

C - storage classes extern and static together ?

Status
Not open for further replies.

rameshbabu

Member level 2
Joined
Aug 1, 2007
Messages
46
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,663
C

Can we use the storage classes extern and static together. For example extern static int i. Give an example of it's usage.
 

Re: C

I dont think it would make much sense to do so?
If 'int i' is extern, then it is global, and by default, static.
Static is used to enable function local variables to retain their value between calls and as a scoping rule to limit the visibility of functions and globels to file scope.
 
Re: C

Extern implies static. Try to think in terms of being the compiler. It needs to know the storage space of the variable. So extern is basically saying to the compiler, here is a variable that I will be using in this file, it is of this type and storage space and I promise that it will be found at some point in another file. This makes the compiler happy. If the variable is not found in another file I believe the compiler is still happy, because it only needs to know the type (for addressing purposes) and the storage space to generate the object file. It is the linker that will choke on the variable not actually being defined.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top