title: What is the difference between "void function()" and "void *function()"?
body: <p>I knew the <code>void *function()</code> is the pointer which point to a function but I don't know how different they work and when we use <code>void *function()</code>?
  I did some research in assembly to compare how they work behind the scene and look like they are same.
  Here is the c++ code:</p>
  
  <pre><code>void *bar(){
          std::cout &lt;&lt; "bar" &lt;&lt; std::endl;
  }
  
  void foo(){
          std::cout &lt;&lt; "foo" &lt;&lt; std::endl;
  }
  
  int main(void){
          foo();
          bar();
  
          return 0;
  }
  </code></pre>
  
  <p>And this is assembly instruction I receive from objdump</p>
  
  <pre><code>void *bar(){
    400846:       55                      push   %rbp
    400847:       48 89 e5                mov    %rsp,%rbp
          std::cout &lt;&lt; "bar" &lt;&lt; std::endl;
    40084a:       be 84 09 40 00          mov    $0x400984,%esi
    40084f:       bf 60 10 60 00          mov    $0x601060,%edi
    400854:       e8 b7 fe ff ff          callq  400710 &lt;_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt&gt;
    400859:       be 30 07 40 00          mov    $0x400730,%esi
    40085e:       48 89 c7                mov    %rax,%rdi
    400861:       e8 ba fe ff ff          callq  400720 &lt;_ZNSolsEPFRSoS_E@plt&gt;
  }
    400866:       90                      nop
    400867:       5d                      pop    %rbp
    400868:       c3                      retq   
  
  0000000000400869 &lt;_Z3foov&gt;:
  
  void foo(){
    400869:       55                      push   %rbp
    40086a:       48 89 e5                mov    %rsp,%rbp
          std::cout &lt;&lt; "foo" &lt;&lt; std::endl;
    40086d:       be 88 09 40 00          mov    $0x400988,%esi
    400872:       bf 60 10 60 00          mov    $0x601060,%edi
    400877:       e8 94 fe ff ff          callq  400710 &lt;_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt&gt;
    40087c:       be 30 07 40 00          mov    $0x400730,%esi
    400881:       48 89 c7                mov    %rax,%rdi
    400884:       e8 97 fe ff ff          callq  400720 &lt;_ZNSolsEPFRSoS_E@plt&gt;
  }
    400889:       90                      nop
    40088a:       5d                      pop    %rbp
    40088b:       c3                      retq   
  
  000000000040088c &lt;main&gt;:
  
  int main(void){
    40088c:       55                      push   %rbp
    40088d:       48 89 e5                mov    %rsp,%rbp
          foo();
    400890:       e8 d4 ff ff ff          callq  400869 &lt;_Z3foov&gt;
          bar();
    400895:       e8 ac ff ff ff          callq  400846 &lt;_Z3barv&gt;
  
          return 0;
    40089a:       b8 00 00 00 00          mov    $0x0,%eax
  }
    40089f:       5d                      pop    %rbp
    4008a0:       c3                      retq   
  </code></pre>