[Issue 7912] Cannot read compile time variable at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 14 21:08:15 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7912



--- Comment #2 from Matt Peterson <revcompgeek at gmail.com> 2012-04-14 21:09:04 PDT ---
Jan: If you want tst to be compile time, use enum instead of const, and just do
"enum uint tst = 0;" or even "enum tst = 0;". The module constructor (static
this() {...}) is called at runtime, and can do a variety of things, including
getting input from the console and other things that the compiler can't
evaluate at compile time. Since you didn't give a value at the declaration of
tst, D requires you to set it in the module constructor as you have done, but
it's not a value that can be read at compile time. I believe if you were to
have done "static const uint tst = 0;" instead, it would have worked, but using
enum instead is a good way to force a variable to be compile time evaluated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list