OR in version conditional compilation
Steven Schveighoffer
schveiguy at gmail.com
Wed Mar 18 16:32:10 UTC 2020
On 3/18/20 12:23 PM, IGotD- wrote:
> I have not seen any example where version has several OR matches.
>
> Example idiom:
>
> version(X86_64 || X86)
> {
>
> }
> else version(ARM || Thumb)
> {
>
> }...
>
> you get the idea. So is this possible at all or do you have to duplicate
> the code for each version identifier despite they are equal for many
> version identifiers?
No, it's not possible. And it won't ever be possible, Walter is dead-set
against it. If you want to know the history, look waaaay back in the
forums. This question comes up every so often.
There is a workaround though:
template v(string versionID)
{
mixin("version(" ~ versionID ~ ") enum v = true; else enum v = false;");
}
static if(v!"X86_64" || v!"X86")
...
-Steve
More information about the Digitalmars-d-learn
mailing list