Re: simple static if / traits question...

2017-02-23 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 23 February 2017 at 18:35:29 UTC, Profile Anaysis wrote: [...] option 1 is the one I was shooting for. does the static if (audio) just check for the existence of audio, or does it also check to see if audio is true as well? Yes, but it checks at compile time. So the code

Re: simple static if / traits question...

2017-02-23 Thread Profile Anaysis via Digitalmars-d-learn
There are a few options: 1. static if(audio) 2. version(audio) 3. if (audio) It looks like you are trying to create the version(audio) semantic(if exists then use, else don't). Ultimately, though, if you are trying to make a binary that can either use audio or not depending on where it is

Re: simple static if / traits question...

2017-02-22 Thread WhatMeForget via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 22:37:25 UTC, Profile Anaysis wrote: On Wednesday, 22 February 2017 at 21:27:47 UTC, WhatMeWorry wrote: I'm doing conditional compilation using static ifs like so: enum bool audio = true; // if audio flag is present and set to true, add to code

Re: simple static if / traits question...

2017-02-22 Thread Profile Anaysis via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 21:27:47 UTC, WhatMeWorry wrote: I'm doing conditional compilation using static ifs like so: enum bool audio = true; // if audio flag is present and set to true, add to code build static if ( (__traits(compiles, audio)) && audio)

Re: simple static if / traits question...

2017-02-22 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 21:27:47 UTC, WhatMeWorry wrote: I'm doing conditional compilation using static ifs like so: enum bool audio = true; // if audio flag is present and set to true, add to code build static if ( (__traits(compiles, audio)) && audio)

simple static if / traits question...

2017-02-22 Thread WhatMeWorry via Digitalmars-d-learn
I'm doing conditional compilation using static ifs like so: enum bool audio = true; // if audio flag is present and set to true, add to code build static if ( (__traits(compiles, audio)) && audio) playSound(soundSys, BLEEP ); This works,