prev up next   top/contents search

comp.lang.c FAQ list · Question 13.27

Q: Why is my simple program, which hardly does more than print ``Hello, world!'' in a window, compiling to such a huge executable (several hundred K)? Should I #include fewer header files?


A: What you're seeing is the current (poor) state of the ``art'' in library design. As run-time libraries accrete more and more features (especially having to do with Graphical User Interfaces), and when one library function calls another library function to do part of its job (which ought to be a Good Thing; that's what library functions are for), it can happen that calling anything in the library (particularly something relatively powerful like printf) eventually pulls in practically everything else, leading to horribly bloated executables.

#including fewer header files probably won't help, because declaring a few functions which you don't call (which is mostly all that happens when you #include a header you don't need) shouldn't result in those functions being placed in your executable, unless they actually do get called. See also question 13.25.

You may be able to track down and derail a chain of unnecessarily-coupled functions which are bloating your executable, or maybe complain to your vendor to clean up the libraries.

References: H&S Sec. 4.8.6 pp. 103-4


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North