Conditional Compilation Multiple Versions

Claude via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 20 02:58:07 PDT 2016


On Saturday, 13 June 2015 at 12:21:50 UTC, ketmar wrote:
> On Fri, 12 Jun 2015 20:41:59 -0400, bitwise wrote:
>
>> Is there a way to compile for multiple conditions?
>> 
>> Tried all these:
>> 
>> version(One | Two){ }
>> version(One || Two){ }
>> version(One && Two){ }
>> version(One) |  version(Two){ }
>> version(One) || version(Two){ }
>> version(One) && version(Two){ }
>> 
>>    Bit
>
> nope. Walter is against that, so we'll not have it, despite the 
> triviality of the patch.

I'm digging up that thread, as I want to do some multiple 
conditional compilation a well.

I have a couple of questions:
* Why is Walter against that? There must be some good reasons.
* Is there an "idiomatic" or "elegant" way of doing it? Should we 
use Mike Parker solution, or use the "template Version(string 
name)" solution (which basically just circumvent "version" 
specific limitation)?

Here' the kind of stuff I'd like to translate from C:

#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
	#define YEP_MICROSOFT_COMPILER
#elif defined(__GNUC__) && !defined(__clang__) && 
!defined(__INTEL_COMPILER) && !defined(__CUDA_ARCH__)
	#define YEP_GNU_COMPILER
#elif defined(__INTEL_COMPILER)
...

#if defined(_M_IX86) || defined(i386) || defined(__i386) || 
defined(__i386__) || defined(_X86_) || defined(__X86__) || 
defined(__I86__) || defined(__INTEL__) || defined(__THW_INTEL__)
	#define YEP_X86_CPU
	#define YEP_X86_ABI
#elif defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) 
|| defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
...


More information about the Digitalmars-d-learn mailing list