What exactly does the compiler switch -betterC do?

docandrew via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 19 17:55:46 PDT 2016


On Sunday, 19 June 2016 at 19:53:46 UTC, 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?

My understanding was that -betterC was not fully implemented yet, 
due mostly to tight compiler integration with the runtime. (old 
info?)

I'm not super smart on the DMD source, but it looks like betterC 
prevents genhelpers() and genModuleInfo() from being called, with 
"helpers" appearing to be array checking, asserts and unit tests.

A comparison of object files compiled with and without the flags 
shows just a small reduction in the size of the code, but 
grepping for bounds checking, unit tests and ModuleInfo in the 
-betterC generated object file shows they are missing.

Hope this helps,

-Jon


More information about the Digitalmars-d-learn mailing list