Delete parts i don't need from header and include files...

Hello all.

Can i delete parts i don't need from header and include files to reduce my executable file size.

For example my code is:

1
2
3
4
5
6
7
8
#include <stdio.h>

int main()
{
   printf ("%s \n", "Hello World!");
   getchar();
   return 0;
}


stdio.h reference is: http://www.cplusplus.com/reference/cstdio/

So i think i could delete these parts from stdio.h file:
Operations on files:
File access:
Direct input/output:
File positioning:
Error-handling:

How do i do that ?
Last edited on
No, that won't decrease your executable file size at all.

If I recall correctly, the linker will only link into your program the stuff it actually needs in order for it to be able to run.
Or at least I think that's the case with .a static libraries.
(not sure about .o object files, though)

If you want to decrease the size of your executable files, here are a few things I can think of (assuming you're using GCC):
-- Strip your executable using strip <my_exe_name_here>.exe or by compiling with -s
-- Try dynamic linking with -shared-libgcc -shared-libstdc++.
-- Compile with -Os if you really care about file size that much.
-- If you don't use dynamic_cast in your code, I heard somewhere that using -fno-rtti will shave off some bytes off of your final executable.
-- Use something like UPX to compress your executable.
Last edited on
Yes what he said. And to answer your question, you cannot delete some parts of header files.
Topic archived. No new replies allowed.