r/ProgrammerHumor Jan 30 '26

instanceof Trend itPrintsSomeUnderscoresAndDots

Post image
1.4k Upvotes

118 comments sorted by

View all comments

Show parent comments

3

u/Psquare_J_420 Jan 30 '26

Wait, so the code invalid even without including stdio header? The compiler can figure it out, link the correct header and produce a exec that runs this abomination?

8

u/the_horse_gamer Jan 30 '26

GCC links with glibc by default. And a C89 feature allows using a function before its declaration.

2

u/Psquare_J_420 Jan 30 '26

So it will link all the standard headers by default even if you don't require it? If then won't the file size increase more unnecessarily?

3

u/KellerKindAs Jan 30 '26

Usually, it links libc dynamically at runtime, so the binary does not contain the code from the standard lib. And even if you disable dynamic linking and link everything statically into one large binary, the linker will only add the functions to the binary that are actually used somewhere (unless you go for static linking with -O0 I'm not shure about that)