digitalmars.D.learn - Compilation constants
- bearophile (17/17) Nov 11 2009 In a C program I have a numeric constant SIZE (that is in [1,32]), that ...
- Phil Deets (4/24) Nov 11 2009 What I would probably do is generate a simple .d file right before you
- Phil Deets (5/33) Nov 11 2009 I'm used to using forums where I can post, look at what I wrote, then ed...
- Phil Deets (2/38) Nov 11 2009 See, I need edit functionality :). s/just be just/just/
- grauzone (5/47) Nov 11 2009 Or use import expressions and mixins, something like
- Phil Deets (5/6) Nov 11 2009 I didn't know it was possible to delete posts from a newsgroup. How do y...
- Chris Nicholson-Sauls (4/10) Nov 12 2009 I don't know about any other readers, but using Thunderbird just right-c...
In a C program I have a numeric constant SIZE (that is in [1,32]), that I can define when I compile the code, like this: gcc -DSIZE=14 ... How can I do the same thing in D? The solution I have found is to put in the D code: version(B1) const SIZE = 1; version(B2) const SIZE = 2; version(B3) const SIZE = 3; version(B4) const SIZE = 4; ... version(B14) const SIZE = 14; ... And then compile the D program with: dmd -version=B14 ... Or: ldc -d-version=B14 ... Do you know nicer ways to do this in D? (if there are no nicer ways, is this simple feature worth adding to D?) Thank you, bye, bearophile
Nov 11 2009
On Wed, 11 Nov 2009 08:50:48 -0500, bearophile <bearophileHUGS lycos.com> wrote:In a C program I have a numeric constant SIZE (that is in [1,32]), that I can define when I compile the code, like this: gcc -DSIZE=14 ... How can I do the same thing in D? The solution I have found is to put in the D code: version(B1) const SIZE = 1; version(B2) const SIZE = 2; version(B3) const SIZE = 3; version(B4) const SIZE = 4; ... version(B14) const SIZE = 14; ... And then compile the D program with: dmd -version=B14 ... Or: ldc -d-version=B14 ... Do you know nicer ways to do this in D? (if there are no nicer ways, is this simple feature worth adding to D?) Thank you, bye, bearophileWhat I would probably do is generate a simple .d file right before you compile.
Nov 11 2009
On Wed, 11 Nov 2009 13:30:17 -0500, Phil Deets <pjdeets2 gmail.com> wrote:On Wed, 11 Nov 2009 08:50:48 -0500, bearophile <bearophileHUGS lycos.com> wrote:I'm used to using forums where I can post, look at what I wrote, then edit if necessary. To continue my thought, the file could be called constants.d and it could contain just be just one line: enum SIZE=14;In a C program I have a numeric constant SIZE (that is in [1,32]), that I can define when I compile the code, like this: gcc -DSIZE=14 ... How can I do the same thing in D? The solution I have found is to put in the D code: version(B1) const SIZE = 1; version(B2) const SIZE = 2; version(B3) const SIZE = 3; version(B4) const SIZE = 4; ... version(B14) const SIZE = 14; ... And then compile the D program with: dmd -version=B14 ... Or: ldc -d-version=B14 ... Do you know nicer ways to do this in D? (if there are no nicer ways, is this simple feature worth adding to D?) Thank you, bye, bearophileWhat I would probably do is generate a simple .d file right before you compile.
Nov 11 2009
On Wed, 11 Nov 2009 13:34:32 -0500, Phil Deets <pjdeets2 gmail.com> wrote:On Wed, 11 Nov 2009 13:30:17 -0500, Phil Deets <pjdeets2 gmail.com> wrote:See, I need edit functionality :). s/just be just/just/On Wed, 11 Nov 2009 08:50:48 -0500, bearophile <bearophileHUGS lycos.com> wrote:I'm used to using forums where I can post, look at what I wrote, then edit if necessary. To continue my thought, the file could be called constants.d and it could contain just be just one line: enum SIZE=14;In a C program I have a numeric constant SIZE (that is in [1,32]), that I can define when I compile the code, like this: gcc -DSIZE=14 ... How can I do the same thing in D? The solution I have found is to put in the D code: version(B1) const SIZE = 1; version(B2) const SIZE = 2; version(B3) const SIZE = 3; version(B4) const SIZE = 4; ... version(B14) const SIZE = 14; ... And then compile the D program with: dmd -version=B14 ... Or: ldc -d-version=B14 ... Do you know nicer ways to do this in D? (if there are no nicer ways, is this simple feature worth adding to D?) Thank you, bye, bearophileWhat I would probably do is generate a simple .d file right before you compile.
Nov 11 2009
Phil Deets wrote:On Wed, 11 Nov 2009 13:34:32 -0500, Phil Deets <pjdeets2 gmail.com> wrote:Or use import expressions and mixins, something like mixin("SIZE="~import("config.txt")); But actually, that's horrible.On Wed, 11 Nov 2009 13:30:17 -0500, Phil Deets <pjdeets2 gmail.com> wrote:On Wed, 11 Nov 2009 08:50:48 -0500, bearophile <bearophileHUGS lycos.com> wrote:I'm used to using forums where I can post, look at what I wrote, then edit if necessary. To continue my thought, the file could be called constants.d and it could contain just be just one line: enum SIZE=14;In a C program I have a numeric constant SIZE (that is in [1,32]), that I can define when I compile the code, like this: gcc -DSIZE=14 ... How can I do the same thing in D? The solution I have found is to put in the D code: version(B1) const SIZE = 1; version(B2) const SIZE = 2; version(B3) const SIZE = 3; version(B4) const SIZE = 4; ... version(B14) const SIZE = 14; ... And then compile the D program with: dmd -version=B14 ... Or: ldc -d-version=B14 ... Do you know nicer ways to do this in D? (if there are no nicer ways, is this simple feature worth adding to D?) Thank you, bye, bearophileWhat I would probably do is generate a simple .d file right before you compile.See, I need edit functionality :). s/just be just/just/You can delete your posts to emulate editing...
Nov 11 2009
On Wed, 11 Nov 2009 13:45:17 -0500, grauzone <none example.net> wrote:You can delete your posts to emulate editing...I didn't know it was possible to delete posts from a newsgroup. How do you do that? -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Nov 11 2009
Phil Deets wrote:On Wed, 11 Nov 2009 13:45:17 -0500, grauzone <none example.net> wrote:I don't know about any other readers, but using Thunderbird just right-click the message header, and there will be a "Cancel Message" command way down toward the bottom. -- Chris Nicholson-SaulsYou can delete your posts to emulate editing...I didn't know it was possible to delete posts from a newsgroup. How do you do that?
Nov 12 2009