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.

Stack and Data Memory variables

Status
Not open for further replies.

A.Rashad

Member level 4
Joined
Jul 27, 2011
Messages
69
Helped
6
Reputation
10
Reaction score
5
Trophy points
1,288
Location
Pune
Activity points
1,792
Can anyone suggest ,

1) When a variable in C will store on Stack?
2) When A variable will be stored on Data memory of controller?

Are these functionality of, 'variable storage area ' is storage class dependent? If yes , Which Storage class, stores variable where?
 


Hi Karthik ,
I gone through these documents, they cleared my confusion now, only thing I want to know is
1>--Does Heap area is the same we call "Data Memory"? Because Global and static variables will be stored on data memory !
2> If I declare variable as static to a file , will other files be able to "just use value of these variables, do not modify these values" or compiler will give directly an error for even non defination of this variable ?
somewhere I read that if we put extern keyword for a static variable then compiler will allocate different different space from data memory for this variable specific to different files, which are using these variable...!!!

to what level its true ?
 

Hi Karthik ,
I gone through these documents, they cleared my confusion now, only thing I want to know is
1>--Does Heap area is the same we call "Data Memory"? Because Global and static variables will be stored on data memory !
2> If I declare variable as static to a file , will other files be able to "just use value of these variables, do not modify these values" or compiler will give directly an error for even non defination of this variable ?
somewhere I read that if we put extern keyword for a static variable then compiler will allocate different different space from data memory for this variable specific to different files, which are using these variable...!!!

to what level its true ?

Hai rashad...

1. Heap memory is mainly used for dynamic allocation functions. like malloc, calloc etc
2. If you declare a variable as static to a file, then the variable is visible just with in the file. You can't access that variable in another file. May be u can pass the value/reference of that variable to another file using function and access.
3. The purpose of a static variable in a file is to make the visibility of the variable with in function. If you put extern to a static variable, then the purpose of static is pointless. This is as good as declaring a extern variable.

Thanks
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top