When is memory allocated during compilation?

后端 未结 8 1865
说谎
说谎 2020-12-18 15:18

When I write

int main()
{
    int j;
}

The memory for j is allocated at the time of compilation, but when during compilation?

相关标签:
8条回答
  • 2020-12-18 15:33

    Compilation generates the executable code for a program. Program memory is allocated when that executable code is run.

    0 讨论(0)
  • 2020-12-18 15:33

    The memory isn't allocated at the time of compilation, but at runtime. The compiler just generated machine code that will execute your program, actual allocations happen at runtime. In this case the variable isn't used and there won't emitted any code for it.

    0 讨论(0)
提交回复
热议问题