Compiling multiple source files --- each file separately, or all together?
David Given
dg at cowlark.com
Fri Dec 26 10:44:21 UTC 2025
When compiling C or C++, and you have multiple source files, you
typically compile each source file independently into a .o file
and then link them together. This is either done manually in the
build script or automatically if you pass multiple source files
into the compiler program.
When compiling D, and I do this:
ldmd2 a.d b.d c.d d.d -o program
...it's unclear to me whether it's doing the same as C/C++ does,
and compiling each file individually, or whether it's compiling
all the .d files together using a single compiler instance. I
_think_ it's compiling them together (and then invoking the
linker as its own stage). Can anyone confirm/deny this? If it's
true, is this true for all dmd-like D compilers?
Context: working on D support for a build tool, and it makes a
big difference to how my tooling would work.
Thanks!
More information about the Digitalmars-d
mailing list