r/C_Programming • • Oct 16 '26

Question Why not specifying what to include ?

Hi, sorry if there is English mistake, it's not my first language.

I found online that the #include is replaced by preprocessor by the whole file being included, and I wondered why C isn't made so we can specify only parts of the files to include (like `import { x, y, z } from "file"` in typescript) so the compiled file is lighter ?

20 Upvotes

28 comments sorted by

View all comments

2

u/Liam_Mercier Oct 16 '26

Historical reasons, complexity of adding module style imports, etc.

There is a system like this in C++ but that is an entirely different language. There is also a lot more of a benefit to reducing compilation times in a language like C++ where you have a lot of instantiations and abstractions, versus a language like C which generally has better compile times.

3

u/torsten_dev Oct 16 '26

c++ modules exist, but I've only heard disgruntled rumblings about it from c++ folk though.