What exactly does the compiler switch -betterC do?

Gary Willoughby via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 19 14:09:39 PDT 2016


On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote:
> On 2016-06-19 21:53, Gary Willoughby wrote:
>> When compiling, what exactly does the -betterC flag do? The 
>> command help
>> says "omit generating some runtime information and helper 
>> functions" but
>> what does this really mean? Is there any specifics somewhere?
>
> It is intended to allow you to link an application without 
> druntime. A Hello World using "extern(C) main" and printing 
> using "printf" contains the following symbols on OS X:
>
> 00000000000000a8 S _D4main12__ModuleInfoZ
> 0000000000000068 T _D4main15__unittest_failFiZv
> 0000000000000018 T _D4main7__arrayZ
> 0000000000000040 T _D4main8__assertFiZv
> 00000000000000b5 s _TMP1
>                  U __d_arraybounds
>                  U __d_assert
>                  U __d_unittest
> 0000000000000000 T _main
>                  U _printf
>
> If compiled with -betterC, it contains these:
>
> 0000000000000000 T _main
>                  U _printf

I get significantly more symbols than that when compiling the 
following program any idea why?

     import core.stdc.stdio;

     extern(C) void main()
     {
         printf("Hello World!\n");
     }


$ rdmd --build-only --force -betterC -de -O -inline -release -w 
test.d
$ nm test



More information about the Digitalmars-d-learn mailing list