Dlang equivalent of #define/#ifdef : not... version
Steven Schveighoffer
schveiguy at gmail.com
Wed Apr 21 14:10:41 UTC 2021
On 4/21/21 2:38 AM, Dukc wrote:
> On Tuesday, 20 April 2021 at 23:58:46 UTC, Steven Schveighoffer wrote:
>> static if(i_am_a_feature) {
>> ...
>> }
> This would be correct if `i_am_a_feature` would be always defined, just
> set to `false` if not existent. But I think the idea was to not define
> the symbol at all if feature does not exists. In that case, the
> condition should be `static if(is(typeof(i_am_a_feature)))`.
Yeah, you're right. It's different than ifdef.
I think version is the closest thing.
Note that you can convert versions into enums via:
version(define_the_thing)
{
enum the_thing_is_defined = 1;
}
else
{
enum the_thing_is_defined = 0;
}
-Steve
More information about the Digitalmars-d-learn
mailing list