What does 'inline' mean?
Johannes Pfau
nospam at example.com
Sat Jun 13 11:31:56 UTC 2020
Am Sat, 13 Jun 2020 01:33:34 -0700 schrieb Walter Bright:
> On 6/12/2020 9:08 PM, Manu wrote:
>> If the di file is mentioned on the command line to the compiler
>>
>> It's not, that's literally the point of a .di file.
>
> No, it isn't. A .di file is more of a convention than a feature. It's a
> module and does not get special treatment by the compiler.
>
>> , yes (1)
>> instance of it appears in the executable. Otherwise, (0) instances
>> of it appear in the executable. There are never 2 or more instances
>> in the executable.
>>
>> Exactly. And this is not a useful design.
>
> I hate to say it, but these sorts of replies are completely useless to
> resolving your issues. You omitted the *why*.
>
> Why can't you put it on the command line?
>
a.di:
void foo() {}
b.d:
import a;
c.d:
import a;
void main() {foo();}
dmd -c b.d
dmd -c c.d
dmd b.o c.o => undefined reference to `_D1a3fooFZv'
dmd -c a.di b.d -ofb.o
dmd -c a.di c.d -ofc.o
dmd b.o c.o => undefined reference to `_D1a3fooFZv'
mv a.di a.d
dmd -c a.d b.d -ofb.o
dmd -c a.d c.d -ofc.o
dmd b.o c.o => multiple definition of `_D1a12__ModuleInfoZ'
dmd -c a.d b.d -ofb.o -betterC
dmd -c a.d c.d -ofc.o -betterC
dmd b.o c.o => OK
BTW: If you do dmd -c a.di you get no object file output. So .di files
are treated differently
I think it's interesting that DMD seems to emit some (all?) normal
functions as weak. Not sure if LDC and GDC do the same thing. Would also
be interesting to see how all this interacts with staic & shared
libraries, though I'm optimistic that it just works.
So basically all that's missing for Manu's inline case would be to emit
pragma(inlne) functions from non-root modules. Probably a 1-line change.
--
Johannes
More information about the Digitalmars-d
mailing list