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

Show parent comment

4

u/Maqi-X Oct 16 '26

No, it isn't. C complication model allows more parallel compilation than many languages with module systems do (for example, rust). In rust you need to split your project into separate crates because modules cannot be compilated simultaneously for whatever reason. Unlike C++, C headers are lightweight and they don't slow down compilation, and if they do you're using them wrong. C has one of the fastest compile times anyway because of how simple language it is.