Re: Inversion of conditional compilation statements

2023-12-02 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:48:02 UTC, Nick Treleaven wrote: On Saturday, 2 December 2023 at 15:03:25 UTC, ryuukk_ wrote: I wish we could use ``version`` as expression, to void the repetition: ```D import std.stdio; enum HasTest = version (Test) ? true : false; Tomek Sowiński wrote t

Re: Inversion of conditional compilation statements

2023-12-02 Thread Nick Treleaven via Digitalmars-d-learn
On Saturday, 2 December 2023 at 15:03:25 UTC, ryuukk_ wrote: I wish we could use ``version`` as expression, to void the repetition: ```D import std.stdio; enum HasTest = version (Test) ? true : false; Tomek Sowiński wrote this template: ```d enum bool isVersion(string ver) = !is(typeof({

Re: Inversion of conditional compilation statements

2023-12-02 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:16:26 UTC, Johannes Miesenhardt wrote: Hello, I am trying to learn D and I have stumbled upon an issue Consider this code: ```d import std.stdio; //version = Test; int main() { version (Test) { writeln("Hello, world!"); }

Re: Inversion of conditional compilation statements

2023-12-02 Thread user1234 via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:16:26 UTC, Johannes Miesenhardt wrote: Hello, [...] I see the way why it doesn't work, but I think it should. Considering that `version (Test) {} else {` works without any issue but looks very ugly. Can somebody explain if this is an intended decision or wh

Inversion of conditional compilation statements

2023-12-02 Thread Johannes Miesenhardt via Digitalmars-d-learn
Hello, I am trying to learn D and I have stumbled upon an issue Consider this code: ```d import std.stdio; //version = Test; int main() { version (Test) { writeln("Hello, world!"); } return 0; } ``` This compiles, however what if we want to turn the versi

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-06 Thread wjoe via Digitalmars-d-learn
On Thursday, 5 August 2021 at 11:54:38 UTC, Mike Parker wrote: On Thursday, 5 August 2021 at 10:43:01 UTC, wjoe wrote: Could you elaborate on ```version(assert)``` a bit more, please ? Like I compiled with ```-release, -g``` and without the 2 options but the ```assert``` branch was always t

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-06 Thread wjoe via Digitalmars-d-learn
On Thursday, 5 August 2021 at 11:01:56 UTC, Adam D Ruppe wrote: On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` You should never use the -release flag. It shou

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 August 2021 at 10:43:01 UTC, wjoe wrote: Could you elaborate on ```version(assert)``` a bit more, please ? Like I compiled with ```-release, -g``` and without the 2 options but the ```assert``` branch was always taken. Could it be that ```-unittest``` has something to do with

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` You should never use the -release flag. It should be renamed to "-enable-security-holes" since that's what it a

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread wjoe via Digitalmars-d-learn
On Thursday, 5 August 2021 at 10:08:12 UTC, Mike Parker wrote: On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: Given that we have `version(assert)` and `version(D_NoBoundsChecks)`, it probably makes sense to also have equivalents to test if contracts are enabled, or if bounds checking

Re: Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 5 August 2021 at 09:18:08 UTC, wjoe wrote: If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` or ```-g``` options, which version identifier is supposed to be used ? There's no ```release``` identifier and

Conditional compilation: Which version identifier for release code ? version(assert) ?

2021-08-05 Thread wjoe via Digitalmars-d-learn
If it's to be determined whether or not the code is being compiled in debug or release mode, i.e. e.g. the dmd ```-release``` or ```-g``` options, which version identifier is supposed to be used ? There's no ```release``` identifier and ```-debug``` switch and ```debug()``` condition are some

Re: What is the equivalent of -version=Flag for conditional compilation in the ldc2 compiler?

2020-06-05 Thread Johan via Digitalmars-d-learn
On Friday, 5 June 2020 at 22:36:23 UTC, data pulverizer wrote: Hi, I was switching from dmd to ldc2 and would like to know the equivalent command line for conditional compilation -version=Flag I was using in dmd. I checked the ldc2 --help but didn't see anything relevant. Version

Re: What is the equivalent of -version=Flag for conditional compilation in the ldc2 compiler?

2020-06-05 Thread data pulverizer via Digitalmars-d-learn
On Friday, 5 June 2020 at 22:39:23 UTC, Steven Schveighoffer wrote: It's in there, I had to do grep to find it: --d-version= - Compile in version code >= or identified by -Steve Thanks, I tried that but didn't realise I still had the old version flag in the command line and

Re: What is the equivalent of -version=Flag for conditional compilation in the ldc2 compiler?

2020-06-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/20 6:36 PM, data pulverizer wrote: Hi, I was switching from dmd to ldc2 and would like to know the equivalent command line for conditional compilation -version=Flag I was using in dmd. I checked the ldc2 --help but didn't see anything relevant. Version there refers to compiler ve

What is the equivalent of -version=Flag for conditional compilation in the ldc2 compiler?

2020-06-05 Thread data pulverizer via Digitalmars-d-learn
Hi, I was switching from dmd to ldc2 and would like to know the equivalent command line for conditional compilation -version=Flag I was using in dmd. I checked the ldc2 --help but didn't see anything relevant. Version there refers to compiler version or some other unrelated things. Thanks

Re: OR in version conditional compilation

2020-03-20 Thread jxel via Digitalmars-d-learn
On Saturday, 21 March 2020 at 00:12:20 UTC, Jonathan M Davis wrote: On Friday, March 20, 2020 4:33:58 PM MDT jxel via Digitalmars-d-learn wrote: On Friday, 20 March 2020 at 21:03:55 UTC, Jonathan M Davis wrote: > On Wednesday, March 18, 2020 10:23:26 AM MDT IGotD- via > > Digitalmars-d-learn wr

Re: OR in version conditional compilation

2020-03-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 20, 2020 4:33:58 PM MDT jxel via Digitalmars-d-learn wrote: > On Friday, 20 March 2020 at 21:03:55 UTC, Jonathan M Davis wrote: > > On Wednesday, March 18, 2020 10:23:26 AM MDT IGotD- via > > > > Digitalmars-d-learn wrote: > >> I have not seen any example where version has several

Re: OR in version conditional compilation

2020-03-20 Thread jxel via Digitalmars-d-learn
On Friday, 20 March 2020 at 21:03:55 UTC, Jonathan M Davis wrote: On Wednesday, March 18, 2020 10:23:26 AM MDT IGotD- via Digitalmars-d-learn wrote: I have not seen any example where version has several OR matches. Example idiom: version(X86_64 || X86) { } else version(ARM || Thumb) { }...

Re: OR in version conditional compilation

2020-03-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 18, 2020 10:23:26 AM MDT IGotD- via Digitalmars-d-learn 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

Re: OR in version conditional compilation

2020-03-18 Thread Kagamin via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=19495#c1

Re: OR in version conditional compilation

2020-03-18 Thread MoonlightSentinel via Digitalmars-d-learn
On Wednesday, 18 March 2020 at 16:23:26 UTC, IGotD- wrote: 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? The usual workaround is to define a common version, e.g. version(X86)

Re: OR in version conditional compilation

2020-03-18 Thread Steven Schveighoffer via Digitalmars-d-learn
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 desp

OR in version conditional compilation

2020-03-18 Thread IGotD- via Digitalmars-d-learn
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

Re: Conditional compilation of array of structs initializer

2017-11-09 Thread Tony via Digitalmars-d-learn
Thanks Mike!

Re: Conditional compilation of array of structs initializer

2017-11-09 Thread Michael V. Franklin via Digitalmars-d-learn
On Friday, 10 November 2017 at 06:22:51 UTC, Tony wrote: Doing a port of some C code that has an #ifdef in the middle of an initialization for an array of structs. I am getting a compile error trying to get equivalent behavior with "static if" or "version". Is there a way to achieve this other

Conditional compilation of array of structs initializer

2017-11-09 Thread Tony via Digitalmars-d-learn
Doing a port of some C code that has an #ifdef in the middle of an initialization for an array of structs. I am getting a compile error trying to get equivalent behavior with "static if" or "version". Is there a way to achieve this other than making two separate array initialization sections?

Re: Conditional Compilation Multiple Versions

2017-01-09 Thread Claude via Digitalmars-d-learn
Druntime uses this for its translation of POSIX header files: https://github.com/dlang/druntime/blob/master/src/core/sys/posix/config.d An example: https://github.com/dlang/druntime/blob/master/src/core/sys/posix/sys/resource.d#L96 Ok, I see. Thanks! (I've gotta try reggae someday) :)

Re: Conditional Compilation Multiple Versions

2017-01-07 Thread Joakim via Digitalmars-d-learn
On Friday, 6 January 2017 at 13:44:37 UTC, Claude wrote: Yes, it works quite well for most use cases and should generally be preferred. I disagree that it scales, though. At some point (a point that is highly project-dependent), it breaks down, requiring either very large modules or duplicated

Re: Conditional Compilation Multiple Versions

2017-01-06 Thread Claude via Digitalmars-d-learn
On Friday, 6 January 2017 at 13:27:06 UTC, Mike Parker wrote: version(Windows) enum bool WindowsSupported = true; else enum bool WindowsSupported = false; Well, yes, that was a bad example. I thought to change it before sending my post but I could find any other meaningful alternative.

Re: Conditional Compilation Multiple Versions

2017-01-06 Thread Mike Parker via Digitalmars-d-learn
Glad hear it's working for you! On Friday, 6 January 2017 at 10:25:26 UTC, Claude wrote: So I had a stream of: version (Win32) enum bool WindowsSupported = true; else enum bool WindowsSupported = false; version (Win64) enum bool WindowsSupported = true; //Ooops else enum bool Windows

Re: Conditional Compilation Multiple Versions

2017-01-06 Thread Claude via Digitalmars-d-learn
On Thursday, 20 October 2016 at 09:58:07 UTC, Claude wrote: I'm digging up that thread, as I want to do some multiple conditional compilation a well. Well I'm digging up that thread again, but to post some positive experience feedback this time as I've found an answer to my

Re: Conditional Compilation Multiple Versions

2016-10-20 Thread Claude via Digitalmars-d-learn
sion(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 question

Re: Conditional compilation inside an array initializer

2016-01-18 Thread Ali Çehreli via Digitalmars-d-learn
On 01/18/2016 04:38 PM, Adam D. Ruppe wrote: On Tuesday, 19 January 2016 at 00:33:21 UTC, Johan Engelen wrote: Is it possible to do conditional compilation inside an array initializer? No, but you might break it up: enum inttable_1 = [1,4]; version(smth) enum inttable_middle = [5,6

Re: Conditional compilation inside an array initializer

2016-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 00:33:21 UTC, Johan Engelen wrote: Is it possible to do conditional compilation inside an array initializer? No, but you might break it up: enum inttable_1 = [1,4]; version(smth) enum inttable_middle = [5,6]; else enum inttable_middle = []; enum

Conditional compilation inside an array initializer

2016-01-18 Thread Johan Engelen via Digitalmars-d-learn
Is it possible to do conditional compilation inside an array initializer? Something like this: int[] inttable = [ 1, 4, version(smth) { // <--- does not compile 5, 6, } 8, 1345 ]; (real world case: https://github.com/ldc-developers/ldc/blob/merge-2.069/ddmd/idgen.d#L

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread bitwise via Digitalmars-d-learn
On Sat, 13 Jun 2015 12:20:40 -0400, ketmar wrote: On Sat, 13 Jun 2015 13:49:49 +, anonymous wrote: Taking it one step further: template Version(string name) { mixin(" version("~name~") enum Version = true; else enum Version = false; "); } static if(Version!"O

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Jun 2015 13:49:49 +, anonymous wrote: > Taking it one step further: > > template Version(string name) > { > mixin(" > version("~name~") enum Version = true; > else enum Version = false; > "); > } > > static if(Version!"One" || Version!"Two") > { >

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread ketmar via Digitalmars-d-learn
On Sat, 13 Jun 2015 12:01:29 -0400, bitwise wrote: >> nope. Walter is against that, so we'll not have it, despite the >> triviality of the patch. > > Any idea what the rationale was for not allowing it? i don't remember. that murmuring about "it makes the code harder to read" goes beyond me, so

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread bitwise via Digitalmars-d-learn
On Sat, 13 Jun 2015 08:21:50 -0400, 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) || versio

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 00:47:37 UTC, Mike Parker wrote: // config.d version(One) enum One = true; else enum One = false; version(Two) enum Two = true; else enum Two = false; // other.d import config; static if(One || Two) { ... } Taking it one step further: template Version(string

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread ketmar via Digitalmars-d-learn
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(T

Re: Conditional Compilation Multiple Versions

2015-06-12 Thread bitwise via Digitalmars-d-learn
On Fri, 12 Jun 2015 20:55:51 -0400, Márcio Martins wrote: I know... I too hate that one can't use simple logic ops... Indeed... Thanks. Bit

Re: Conditional Compilation Multiple Versions

2015-06-12 Thread via Digitalmars-d-learn
On Saturday, 13 June 2015 at 00:42:00 UTC, bitwise wrote: Is there a way to compile for multiple conditions? version(One) version = OneOrTwo; else version(Two) version = OneOrTwo; version(OneOrTwo) { writeln("moo"); } --- version(One) version(Two) version = OneAndTwo; version(OneAndTwo)

Re: Conditional Compilation Multiple Versions

2015-06-12 Thread Mike Parker via Digitalmars-d-learn
On 6/13/2015 9:41 AM, 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 // config.d vers

Conditional Compilation Multiple Versions

2015-06-12 Thread bitwise via Digitalmars-d-learn
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

Re: Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:24:53 UTC, Namespace wrote: On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote: On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } Thanks for the quick reply! Worth a

Re: Conditional compilation for debug/release

2015-04-06 Thread Namespace via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote: On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } Thanks for the quick reply! Worth adding an example like that to http://dlang.org/version.h

Re: Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote: debug { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } Thanks for the quick reply! Worth adding an example like that to http://dlang.org/version.html ?

Re: Conditional compilation for debug/release

2015-04-06 Thread Namespace via Digitalmars-d-learn
On Monday, 6 April 2015 at 14:50:29 UTC, Johan Engelen wrote: How do conditionally compile code for either release ("-release") or debug ("-debug")? Something like this: version(Debug) { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } In the documentation [1], I don't

Conditional compilation for debug/release

2015-04-06 Thread Johan Engelen via Digitalmars-d-learn
How do conditionally compile code for either release ("-release") or debug ("-debug")? Something like this: version(Debug) { pragma(lib, "libcmtd.lib"); } else { pragma(lib, "libcmt.lib"); } In the documentation [1], I don't see any predefined version identifiers for this purpose. Th

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-01-07 20:48, Jonathan Marler wrote: I've looked up the windows version helper functions (http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx). The problem is that these functions are not defined in DMD's user32.lib. I could use the operating system's user32.

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Paulo Pinto via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 19:48:16 UTC, Jonathan Marler wrote: On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP o

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 18:50:40 UTC, Jacob Carlborg wrote: On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which

Re: Conditional Compilation for Specific Windows

2015-01-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-01-07 19:27, Jonathan Marler wrote: I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which version of windows you are on? Note: I'm specifically talking about r

Conditional Compilation for Specific Windows

2015-01-07 Thread Jonathan Marler via Digitalmars-d-learn
I'm looking at the Windows multicast API. It has different socket options depending on if you are on Windows XP or Windows Vista (and later). Is there a way to tell at runtime which version of windows you are on? Note: I'm specifically talking about runtime because I want the same binary to r

Re: DMD Compiler Version Dependent Conditional Compilation

2014-06-09 Thread Nordlöw
Thx

Re: DMD Compiler Version Dependent Conditional Compilation

2014-06-09 Thread David Nadlinger via Digitalmars-d-learn
On Monday, 9 June 2014 at 17:36:10 UTC, Nordlöw wrote: Can I use the version keyword or static if to perform conditional compilation that depends on the version of DMD? The __VERSION__ magic token should do the job. David

DMD Compiler Version Dependent Conditional Compilation

2014-06-09 Thread Nordlöw
Can I use the version keyword or static if to perform conditional compilation that depends on the version of DMD? I typicall something like version(>= DMD_2.0.66) { // use new byChar, byWchar, byDchar, byCodepoint } else { // use old style slower version } If so how?

Re: Conditional compilation

2013-06-08 Thread Chris Nicholson-Sauls
There is the aforementioned extern(system), which is probably your best bet. But I'm wondering if your design could seperate the connection to IUnknown for non-Windows builds? Something like this: version(Windows) interface _Inter_ : IUnknown {} else interface _Inter_ {} // later interface

Re: Conditional compilation

2013-06-07 Thread Anthony Goins
On Friday, 7 June 2013 at 12:20:23 UTC, finalpatch wrote: string mixins and template mixins don't work either. On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote: Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. It's

Re: Conditional compilation

2013-06-07 Thread Mike Parker
On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote: Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. extern(System) On Windows, it will be seen by the compiler as extern(Windows), elsewhere as extern(C).

Re: Conditional compilation

2013-06-07 Thread finalpatch
string mixins and template mixins don't work either. On Friday, 7 June 2013 at 12:14:45 UTC, finalpatch wrote: Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. It's something like this: OSX: interface InterfaceA : IUnknow

Conditional compilation

2013-06-07 Thread finalpatch
Hi folks, I need to apply different calling conventions to the same interfaces when compiling for different platform. It's something like this: OSX: interface InterfaceA : IUnknown { extern(C): ... } Windows: interface InterfaceA : IUnknown { ... } I have to add extern(C) on OSX b

Re: Conditional compilation for non-release version

2012-04-28 Thread Joseph Rushton Wakeling
On 28/04/12 15:03, F i L wrote: Or you could use debug statements: Yes, that was what I wanted to avoid -- I wanted the tests to be there by default, not only when debugging ... :-) AFAICS the foreach loop probably does get optimized out by the compiler (I'm using GDC); if anything is left,

Re: Conditional compilation for non-release version

2012-04-28 Thread F i L
asserts aren't compiled into release builds (except assert(false)). So, if the loop only contains asserts, the compiler *should* be able to strip out the loop altogether. I don't know if DMD actually does that, though. Or you could use debug statements: debug foreach (x; largeArray) {

Re: Conditional compilation for non-release version

2012-04-28 Thread Timon Gehr
On 04/28/2012 02:05 PM, Joseph Rushton Wakeling wrote: Hello all, I've just been reading through this page: http://dlang.org/version.html Is there a way to put in place a conditional segment of code that is included if the code is _not_ compiled with the -release flag? Of course I can put in a

Re: Conditional compilation for non-release version

2012-04-28 Thread bearophile
Joseph Rushton Wakeling: Is there a way to put in place a conditional segment of code that is included if the code is _not_ compiled with the -release flag? Contract programming? D is designed to make it hard on purpose to do what you want to do. The reason I'm asking is because the checks

Conditional compilation for non-release version

2012-04-28 Thread Joseph Rushton Wakeling
Hello all, I've just been reading through this page: http://dlang.org/version.html Is there a way to put in place a conditional segment of code that is included if the code is _not_ compiled with the -release flag? Of course I can put in a debug statement, but that would require me to compile

Re: Conditional Compilation with Version

2011-09-23 Thread alex
O... So I if it is in my main function (which I think it is) I should move it out? That makes sense... Thank you Timon!!

Re: Conditional Compilation with Version

2011-09-22 Thread Timon Gehr
On 09/22/2011 04:17 AM, alex wrote: Hi Y'all!! Just as a note, I am new to the news group, but slightly less new to D =) Back on topic: I am unable to get multiple version specifications to work (from the website) sometihng like: version (foo) { version = bar; version = baz; } version (bar) {

Conditional Compilation with Version

2011-09-21 Thread alex
Hi Y'all!! Just as a note, I am new to the news group, but slightly less new to D =) Back on topic: I am unable to get multiple version specifications to work (from the website) sometihng like: version (foo) { version = bar; version = baz; } version (bar) { ... codes 'n' stuff } ve

Semantics of specialization, constraints, and conditional compilation

2010-05-20 Thread Ali Çehreli
Mostly babbling... Please comment here and there... :) What are the semantics of the three? What are your guidelines when choosing among them? Is my understanding below correct? Have I missed other related D features? - specialization means "there is a general definition somewhere; but this