What exactly does the compiler switch -betterC do?

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 19 23:35:32 PDT 2016


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
-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list