Comment #0 by joaopaulo1339 — 2019-05-15T12:25:10Z
Created attachment 1745
Compilation example
This code compiles just fine with dmd 2.0.86 and betterC enabeld
pragma(msg, __VERSION__);
import core.stdc.stdio : printf;
interface ITeste {
void some();
}
class Teste : ITeste {
void some() {
version (D_BetterC) {
printf("test\n");
}
}
}
void main() {
Teste t = new Teste();
t.some();
}
Comment #2 by joaopaulo1339 — 2019-05-15T13:36:39Z
(In reply to Seb from comment #1)
> Why should it?
> What gave you the impression that it should be?
>
> BetterC doesn't support class allocation (via GC) yet.
>
> In general, classes are a bit challenging with betterC
>
> Though, I recommend reading this great article:
>
> https://theartofmachinery.com/2018/08/13/inheritance_and_polymorphism_2.html
Because D BetterC page list classes as an removed feature
https://dlang.org/spec/betterc.html#consequences
So, if classes are removed, why my example compiles just fine?
Comment #3 by alphaglosined — 2019-05-15T13:43:49Z
The above snippet does indeed compile and run on Windows (I added the pragma).
dmd is including druntime/phobos into the build automatically and has since at least 2.082. Which is providing symbols that shouldn't be available (run.dlang.org it fails on as expected).
Comment #4 by kinke — 2019-05-15T19:09:32Z
The reason for this behavior is apparently the extern(D) main function. Make that extern(C), and druntime/Phobos isn't linked. - There's a DMD special case for Windows targets, where the object file containing the D main function gets an embedded linker directive to pull in the library.