D alternative for C/C++ -Dfoo=42

Francesco Cattoglio francesco.cattoglio at gmail.com
Tue Feb 25 06:38:33 PST 2014


On Tuesday, 25 February 2014 at 14:30:23 UTC, Francesco Cattoglio 
wrote:
> On Tuesday, 25 February 2014 at 14:26:13 UTC, Tobias Pankrath 
> wrote:
>>> Something like "static if(fileExists!"config.d") 
>>> mixin(import("config.d")) else ...".
>>>
>>> Thoughts?
>>>
>>> Regards
>>> - Cherry
>> --
>> static if(__traits(compiles, import("config.d")))
>> {
>> // import/parse/mixin
>> }
>> else
>> {
>> // default here
>> }
>> --
>>
>> May be wrapped into a template for more convenience.
>
> I thought that too... And then, when I tried, SURPRISE, it 
> doesn't work :S
Ok, MY BAD! It works, but I gave him a folder instead of a file. 
When you give it a folder instead of a file, it still works but 
also outputs an error:
read error, errno = 21
However the "else" branch is still taken. Well, this went better 
than expected!


More information about the Digitalmars-d-learn mailing list