digitalmars.D.learn - Undefined identifier error with enum in the separate module
- =?UTF-8?B?TmVtYW5qYSBCb3JpxIc=?= (22/22) Feb 01 2014 Hello,
- evilrat (6/29) Feb 01 2014 it is recommended to name module in lower case only. and in your
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
Feb 01 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, Nemanjait 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;
Feb 01 2014