Re:Trying out C++20's modules with Clang and Make
by chacham15 on Sunday October 15, 2023 @01:12PM
(#37891521)
IIRC the main point of header files was to make compilation 1 pass instead of 2. I.e. when the compiler is processing a function and sees `int a = foo(bar, baz);` how does it know what code to generate here? How do you call foo (i.e. what calling convention does foo have)? Furthermore, how do you know if the code is valid? Do the passed arguments match the declared arguments? What if there is function overloading? How does it know which actual function to call? A lot of other compilers will do two-passes where they scan the code once to compile all of that information, and then do it a second time to then actually write the code out. The optimization for c/c++ was to "cache" the declarations separately in a header file, so that you dont need to parse/scan twice.
[ Parent
| on HN ]
There are no comments on this comment yet.