Add ImportC compiler to dmd

Max Haughton maxhaton at gmail.com
Mon May 10 02:16:47 UTC 2021


On Monday, 10 May 2021 at 01:50:40 UTC, Brian wrote:
> On Monday, 10 May 2021 at 01:13:25 UTC, Max Haughton wrote:
>>[...]
>
> Whether or not your code links in C depends on a number of 
> factors. It is not as simple as you make it out to be.
>
> Consider on my OpenBSD machine:
> ```
> /home/brian/c $ gcc --version
> gcc (GCC) 12.0.0 20210421 (experimental)
> Copyright (C) 2021 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  
> There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A 
> PARTICULAR PURPOSE.
>
> /home/brian/c $ gcc -o square square.c
> ld: error: undefined symbol: square
>>>>               [...]
> collect2: error: ld returned 1 exit status
> /home/brian/c $ gcc -O2 -o square square.c
> /home/brian/c $ ./square
> 9
> ```
>
> ~Brian

That particular case is fairly simple if you look at the 
outputted code. The function `square` is never emitted, but with 
the optimization flag it is never used (by name).


More information about the Digitalmars-d mailing list