module's constants and forward references

Serg Kovrov dyh at pathlink.com
Sat Jul 8 19:04:41 PDT 2006


Hi all,

I'm truing to convert some c-headers, and run into problems with 
constants in module scope.
Here is simplified example:

----------------------
module test;
import def;
const VAL = 1;
void main(...
----------------------
module def;
import test;
const DVAL = VAL + 1;
----------------------

When I try to compile test.d, i've got:
"def.d(5): forward reference of VAL"
But if I use int instead of const, everything compiles as expected. 
Could someone explain why the difference and how to have it as constants 
(as they was #define'd in c-header files)?

Thanks.

PS dmd v0.162
--
Serg.



More information about the Digitalmars-d-learn mailing list