   Removing uncalled functions
  I'm experimenting with reducing exe size and procedural content in my game, sort of demoscene-ish.  I'm down to 18KB.  I could go farther if I removed various uncalled functions that are part of my personal "standard" library, and a few functions I think standard windows libraries are sneaking in.I was under the impression that the linker would do this for me, but it doesn't.  This doesn't seem to me to be something terribly difficult.  A top-of-the-head solution:while !done  1.  go through all the searching for function calls, keeping booleans on wether a function is ever called from another function somewhere or not (true).  2.  Remove any functions whos boolean is still false.  3.  If no functions were removed, done = true.So either I'm missing something in the compiler options (MSVC 6.0), I'm not properly understanding compiler theory, or there's an application somewhere to do this for me.Does anyone have any ideas?   
  There is definitely a strip unused symbols thing. Perhaps it's time to get a new (better) compiler (newer GCC is FAR better than old MSVC).   ;  I'm not sure about MSVC6.0, but all later versions of MSVC can do this - all you need is /OPT:REF (linker).   ;  I'm not too keen on switching compilers, it's taken me too long to figure out the quirks of the one I have ;)I think I found it, it must have been disabled through something the first time around.  Had to read through the MSDN for the compiler.I've gotten my app down to 13,312 bytes, which isn't bad considering that it's a simple 3D mouselooker.   ;Quote:Original post by NumsgilI'm not too keen on switching compilers, it's taken me too long to figure out the quirks bugs of the one I have ;)You're talking about MSVC6. GCC and MSVC7.1/MSVC8 have eccentricities, MSVC6 has bugs, or for the Politically Correct, it is standards conforming challenged.   ;  They're not bugs because that's the way it was designed.  It came out before the standardization of C++, so there are some small hurdles (templates among them), but once you learn them it's no different from any other language.   ;Quote:Original post by Numsgil... I could go farther if I removed various uncalled functions that are part of my personal "standard" library, ...... A top-of-the-head solution:while !done  1.  go through all the searching for function calls, keeping booleans on wether a function is ever called from another function somewhere or  not (true).  2.  Remove any functions whos boolean is still false.  3.  If no functions were removed, done = true.If you want to switch to GCC, that is possible. During compilation you may pass the compiler option "-ffunction-sections" and/or "-fdata-sections". This will put each function into its own section. When linking the object files together, you can pass "--gc-sections" to the linker. This will do the three steps you wrote above. Maybe you will need to write a linker script marking the initial function(s) with KEEP(), giving a starting point for the search of reachable code.The links to the documentation of GCC and LD:http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Optimize-Options.html#index-ffunction_002dsections-576http://sourceware.org/binutils/docs-2.16/ld/index.html;Quote:Original post by NumsgilThey're not bugs because that's the way it was designed.  It came out before the standardization of C++, so there are some small hurdles (templates among them), but once you learn them it's no different from any other language.That dosn't change the fact that I can't call it a C++ compiler without feeling like I'm lying, nor the fact that newer compilers can optimize better, support more complex templates, and have the simple features that you can't seem to find on VS6.0.Here's the option on VS2k5 Express, which is available for free from Microsoft for download: