Module without object file?
Steven Schveighoffer
schveiguy at gmail.com
Thu Jan 6 02:47:17 UTC 2022
On 1/4/22 5:17 PM, kdevel wrote:
> Is there any chance to rephrase fsobjects.d such that it becomes a
> "header only"/"compile only" file of which no object file must be
> presented to the linker?
Possibly. You see, you are importing another module. Since you are doing
that, the module must participate in cycle detection at the beginning of
running the program.
The way D does this is to store the import graph inside a `ModuleInfo`
struct stored in the object.
When you import this file, the compiler sees that it has imports, and
assumes you must have built the `ModuleInfo` in some object somewhere,
so it outputs a reference for the import graph.
What *might* work is to make all your things templates, which by
definition are processed when instantiated, and then inside those
template, do your imports. But I'm not sure, the compiler might still
require the `ModuleInfo`.
-Steve
More information about the Digitalmars-d-learn
mailing list