How do C compilers implement functions that return large structures?

前端 未结 5 2014
长发绾君心
长发绾君心 2020-11-29 05:04

The return value of a function is usually stored on the stack or in a register. But for a large structure, it has to be on the stack. How much copying has to happen in a rea

5条回答
  •  醉酒成梦
    2020-11-29 05:43

    gcc on linux will issue a memcpy() to copy the struct back on the stack of the caller. If the function has internal linkage, more optimizations become available though.

提交回复
热议问题