Why do books say, “the compiler allocates space for variables in memory”?

前端 未结 7 1555
我在风中等你
我在风中等你 2020-12-31 10:54

Why do books say, \"the compiler allocates space for variables in memory\". Isn\'t it the executable which does that? I mean, for example, if I write the following program

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-31 11:44

    Suggest you to read compiler construction. Focus on the storage phase, your query would be resolved.

    After the program gets compiled its converted to object code, which is an assembly language code. every line of a high level language program gets translated to many assembly language steps. The translated program is put into the assembler which is executed. There is STORAGE assignment phase in comiler construction which translates to Machine Operation table(MOT instructions at assembly level). This is where space allocation for variables/registers is done. There is a register modifier keyword in C++ as well.

提交回复
热议问题