If a constant is defined globally, it goes to the text
segment. Local constants get pushed onto the stack
. Static variables get stored into either the data
or the bss
segment depending on if it is initialised in place and what it is initialised with.
What about static const
? This question links to another one which is only about static variables, not constants. I suppose static constants should be stored in the text
segment as read-only variables, but I'm not sure. Where is it commonly stored?