February 01, 2014 Undefined identifier error with enum in the separate module | ||||
---|---|---|---|---|
| ||||
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 Re: Undefined identifier error with enum in the separate module | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nemanja Borić | 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;
|
Copyright © 1999-2021 by the D Language Foundation