Where is the function declared as static stored in memory?

The usage of static with a function or variable restricts their scope.Is this behaviour memory related?

Questions by vjaya   answers by vjaya

Showing Answers 1 - 5 of 5 Answers

I am assuming you are asking in terms of where the function is stored in memory as in if it is stored in Code segment, stack, heap, bss.

I am not sure but it is stored in the Code segment. Correct me if I am wrong

  Was this answer useful?  Yes

The keyword static dose not effect the sorage of function as it dose in case of variable a static variable means that it is stored in static dat  section but a static function dose not mean that alhough it means this function would not be accessibe in the other file.

  Was this answer useful?  Yes

Jeevan

  • Sep 1st, 2014
 

Yes static keyword would not effect where the function gets stored, even if it is static a function will always be stored in stack! But it hides the function from being used in other files other than in which it is declared.

  Was this answer useful?  Yes

Harsha

  • Mar 27th, 2019
 

You have to specify where you are going to place it. You can do this in the linker file(.lsl or .ld file). If you place it in the .text section, it goes into the Flash, else by default a static function is placed in the RAM(.data).

  Was this answer useful?  Yes

jbode

  • Jun 5th, 2019
 

The static keyword does not affect where or how a function is stored in memory. It only affects whether the function *name* is visible to code outside of the current translation unit (source file).

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions