Inline function prototype vs regular declaration vs prototype

前端 未结 4 992
别那么骄傲
别那么骄傲 2020-12-21 09:02

What\'s the difference between inline function and then main like so:

inline double cube(double side)
{
   return side * side * side;
}

int main( )
{
    cu         


        
4条回答
  •  不思量自难忘°
    2020-12-21 09:36

    The 3 program compile to exactly the same with g++ -S -O3 $file.cc. Except for the second example where the definition of double cube(double side) still exist in a non inlined form though inlined in int main().

    _main:
    pushl   %ebp
    movl    $16, %eax
    movl    %esp, %ebp
    subl    $8, %esp
    andl    $-16, %esp
    call    __alloca
    call    ___main
    leave
    xorl    %eax, %eax
    ret
    

提交回复
热议问题