A case for -H header files, avoid repeating expensive compile-time calculations
cy via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 27 11:34:50 PDT 2016
I made a module that looped for a while in compile time (since
you can't sleep during compile time), to see if I could
pre-compile the module, and thus save time compiling the main
application. It didn't work at first, because any file that
depended on the module would import it, and importing it would
execute the compile time code again, thus taking a long time to
compile... twice.
But then I remembered about the rarely used -H option for dmd. -H
outputs a stripped down version of the source file being
compiled, with all the function definitions replaced with
declarations. So if your expensive to compile code is
encapsulated within a function... it doesn't appear in the -H
output.
So uh... git://critter.cloudns.org/test-dlang-encapsulation I
guess. It might be a neat trick to speed up compilation, if you
have a lot of complicated code that can be hidden behind a simple
interface.
More information about the Digitalmars-d
mailing list