February 01, 2014
Hello,

I am having troubles to use the enum defined in the separate module.
When I try to access it, I am getting "Undefined symbol" error:


// CodeEnum.d

enum CodeEnum
{
	OK = 200,
	FAIL = 400
}

unittest
{
	auto e = CodeEnum.OK; // Works!
}


// Reply.d
import CodeEnum;

unittest
{
	auto.e = CodeEnum.OK; // Error: undefined identifier 'OK'
}


What I am doing wrong?

Thanks,
Nemanja

February 02, 2014
On Saturday, 1 February 2014 at 21:00:18 UTC, Nemanja Borić wrote:
> Hello,
>
> I am having troubles to use the enum defined in the separate module.
> When I try to access it, I am getting "Undefined symbol" error:
>
>
> // CodeEnum.d
>
> enum CodeEnum
> {
> 	OK = 200,
> 	FAIL = 400
> }
>
> unittest
> {
> 	auto e = CodeEnum.OK; // Works!
> }
>
>
> // Reply.d
> import CodeEnum;
>
> unittest
> {
> 	auto.e = CodeEnum.OK; // Error: undefined identifier 'OK'
> }
>
>
> What I am doing wrong?
>
> Thanks,
> Nemanja

it is recommended to name module in lower case only. and in your particular case compiler think you accessing module CodeEnum which contains symbol OK. so either give another name to module, or fully specify what you are trying to accesss - auto e = CodeEnum.CodeEnum.OK;