Bug 1781 – Conditional Compilation - debug ( Integer ) is to restrictive
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-01-11T04:18:55Z
Last change time
2019-08-26T13:38:02Z
Keywords
spec
Assigned to
No Owner
Creator
danijans03
Comments
Comment #0 by danijans03 — 2008-01-11T04:18:55Z
It is currently not possible to write something like:
enum DebugLevel { LOW, MEDIUM, HIGH };
debug(DebugLevel.HIGH)
Logger.writeDebug("");
I think it is to restrictive to only allow Integer. An enum could easily be cast to an integer internally.
You could of course write something like:
const int DebugLevelLow = 0;
const int DebugLevelMedium = 1;
const int DebugLevelHigh = 2;
debug(DebugLevelHigh)
Logger.writeDebug("");
But this isn't as elegant as using enums.
Comment #1 by bearophile_hugs — 2010-05-12T03:01:50Z
There is also this syntax:
debug ( Identifier )
So you can use:
debug(MEDIUM)
Logger.writeDebug("");
To be compiled with:
-debug=MEDIUM