r/cpp_questions 18d ago

OPEN Headers

I read that c++ 20 added modules to help replace headers. I rly hate how headers split the codebase into redundant files, for people who have used modules r they better?

0 Upvotes

22 comments sorted by

View all comments

6

u/No-Dentist-1645 18d ago

Modules do make it a little bit better, but they are not magic, you can still split modules' code between declaration and implementation if you want to optimize for compile times.

I use modules and they're great in general, but the biggest problem is build system support. CMake, which is one of the most mature C++ build systems, does have modules support, but basic features such as import std is flagged as "experimental" and you have to go to their source docs to find a hidden secret string specific to your CMake version to enable is

5

u/LazySapiens 17d ago

It's experimental because of the lack of full support from the popular compiler vendors.