"version" private word
bauss
jj_1337 at live.dk
Tue Oct 31 19:58:03 UTC 2017
On Tuesday, 31 October 2017 at 13:55:56 UTC, Igor Shirkalin wrote:
> On Tuesday, 31 October 2017 at 13:53:54 UTC, Jacob Carlborg
> wrote:
>> On 2017-10-31 14:46, Igor Shirkalin wrote:
>>> Hello!
>>>
>>> We need some conditional compilation using 'version'.
>>> Say we have some code to be compiled for X86 and X86_64.
>>> How can we do that using predefined (or other) versions?
>>> Examples:
>>>
>>> version(X86 || X86_64) // failed
>>> version(X86) || version(X86_64) // failed
>>>
>>>
>>> The following works but it is too verbose:
>>>
>>> version(X86) {
>>> version = X86_or_64;
>>> }
>>> version(X86_64) {
>>> version = X86_or_64;
>>> }
>>
>> The only alternative is to do something like this:
>>
>> version (X86)
>> enum x86 = true;
>> else
>> enum x86 = false;
>>
>> else version (X86_64)
>> enum x86_64 = true;
>> else
>> enum x86_64 = false;
>>
>> static if (x86 || x86_64) {}
>
> Got it. Thank you!
Yeah, in Diamond I went with this approach to make conditional
compilation around the project much easier.
https://github.com/DiamondMVC/Diamond/blob/master/core/apptype.d
More information about the Digitalmars-d-learn
mailing list