Re: Neater "not version (...)" ?

2020-09-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-16 21:04, Vladimirs Nordholm wrote: Ah, I guess it boils down to this then. Doesn't really make it "neater", but thank you for the tip! You only need to declare the enums ones. -- /Jacob Carlborg

Re: Neater "not version (...)" ?

2020-09-16 Thread Dennis via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 19:04:24 UTC, Vladimirs Nordholm wrote: Ah, I guess it boils down to this then. Doesn't really make it "neater", but thank you for the tip! IMO, just keep it as `version(Windows) {} else { ... }` if you HAVE to instead of one of the workarounds people

Re: Neater "not version (...)" ?

2020-09-16 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 19:04:24 UTC, Vladimirs Nordholm wrote: On Wednesday, 16 September 2020 at 18:54:45 UTC, Jacob Carlborg wrote: version (Windows) enum windows = true; else enum windows = false; static if (!windows) { // ... my code } Ah, I guess it boils down to

Re: Neater "not version (...)" ?

2020-09-16 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 18:54:45 UTC, Jacob Carlborg wrote: On 2020-09-16 19:53, Vladimirs Nordholm wrote: Hello. I wonder if there is a better way to compile something if the current operating system is _not_ a specific platform. For example, I only want some code to compile if

Re: Neater "not version (...)" ?

2020-09-16 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 18:07:25 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 16 September 2020 at 17:53:31 UTC, Vladimirs Nordholm wrote: Hello. I wonder if there is a better way to compile something if the current operating system is _not_ a specific platform. For example, I only

Re: Neater "not version (...)" ?

2020-09-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-16 19:53, Vladimirs Nordholm wrote: Hello. I wonder if there is a better way to compile something if the current operating system is _not_ a specific platform. For example, I only want some code to compile if the operating system is not Windows. Currently I do this:    

Re: Neater "not version (...)" ?

2020-09-16 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 17:53:31 UTC, Vladimirs Nordholm wrote: Hello. I wonder if there is a better way to compile something if the current operating system is _not_ a specific platform. For example, I only want some code to compile if the operating system is not Windows.

Re: Neater enum + version

2018-11-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-11-18 18:52, Neia Neutuladh wrote: On Sun, 18 Nov 2018 17:47:07 +, Vladimirs Nordholm wrote: Is there anyway to make it "neater"? Maybe something in one line: enum foo = version (Posix) { "posix" } : { "other" } ; If you're doing it often: T ifPosix(T)(T a, T b) {

Re: Neater enum + version

2018-11-18 Thread Vladimirs Nordholm via Digitalmars-d-learn
On Sunday, 18 November 2018 at 17:52:21 UTC, Neia Neutuladh wrote: On Sun, 18 Nov 2018 17:47:07 +, Vladimirs Nordholm wrote: Is there anyway to make it "neater"? Maybe something in one line: enum foo = version (Posix) { "posix" } : { "other" } ; If you're doing it often: T

Re: Neater enum + version

2018-11-18 Thread Neia Neutuladh via Digitalmars-d-learn
On Sun, 18 Nov 2018 17:47:07 +, Vladimirs Nordholm wrote: > Is there anyway to make it "neater"? Maybe something in one line: > > enum foo = version (Posix) { "posix" } : { "other" } ; If you're doing it often: T ifPosix(T)(T a, T b) { version (Posix) return a; else return b; } enum