how do compilers assign memory addresses to variables?

后端 未结 4 1338
你的背包
你的背包 2020-12-07 14:57

I teach a course where students get to ask questions about programming (!): I got this question:

Why does the machine choose were variables go in memo

4条回答
  •  醉话见心
    2020-12-07 15:49

    I would like to add few. For firmware where you know the memory map and run address, and where you compile source using your own linker script-

    You can assign a custom section to a variable using section attribute and then assign a particular address to custom section through linker script. Then variable would get a fixed/assigned address.

提交回复
热议问题