Zero-cost version-dependent function call at -O0.
Johan Engelen via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 25 14:55:22 PDT 2017
On Sunday, 25 June 2017 at 16:31:52 UTC, Moritz Maxeiner wrote:
> On Sunday, 25 June 2017 at 15:58:48 UTC, Johan Engelen wrote:
>> [...]
>> If version(X) is not defined, there should be no call and no
>> extra code at -O0.
>> [...]
>>
>> In C, you could do something like:
>> ```
>> #if X
>> void foo() {......}
>> #else
>> #define foo()
>> #endif
>> ```
>>
>> How would you do this in D?
>
> By requiring the compiler to inline the empty foo:
This won't work. Semantically, there is still a call and e.g.
profiling will see it:
https://godbolt.org/g/AUCeuu
-Johan
More information about the Digitalmars-d-learn
mailing list