Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Puzzler183

Will GCC include my unused functions in the exectuable?

This topic is 5450 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
I know adding /opt:ref to the MSV6 compiler options will ensure that no extra code is added. Look for something similar with gcc.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!