What is this undefined reference with -betterC about?
Dennis
dkorpel at gmail.com
Wed Jun 16 16:27:13 UTC 2021
On Wednesday, 16 June 2021 at 14:38:10 UTC, jfondren wrote:
> What do I change to
> 1. a script like this that uses hostname
> 2. the hostname module
>
> so that both can be built with -betterC when and only when
> the script is using -betterC?
That's currently the situation: you can only build when both are
betterC or else you get a linker error. It has to be a linker
error, dmd cannot know at the time of compiling project A how
project B is going to be compiled and vice versa.
It noticed your code looks like this:
```D
version(D_BetterC) {
char* hostnamez;
} else {
immutable char* hostnamez;
}
```
The different types result in different mangles, causing the
linking errors. Why not simply give them the same type?
More information about the Digitalmars-d-learn
mailing list