   Will GCC include my unused functions in the exectuable?
  Will GCC include my unused functions in the exectuable?  
quote:Original post by Puzzler183  Will GCC include my unused functions in the exectuable? I am not sure but I think unused portions of code get removed from the executable.  ;  That''s what I thought, just wasn''t sure.  ;  Code which is actually compiled into functions will remain in the executable, whether you use it or not, it would just be lots of pointless work for the linker (and this is the stage which would have to do the removal) to remove individual functions.  Now for purely inlined code (such as templates), sure, they won''t be included if not used.The real question is why should you care?  ;  I know adding /opt:ref to the MSV6 compiler options will ensure that no extra code is added. Look for something similar with gcc. ;  gcc will remove dead code, and unused static or "inline" functions (i believe also unused c++ anonymous namespace functions)ld is responsible for removing non-static/inline unused functions.ld has some option like --whole-archive that''ll keep all your functions intact. 