W
Wiseguy
I have an enum defined within a namespace. When I reference the enum
using its qualified name graphics::db_status(VALUE) it does not work.
If I say "using namespace graphics;" then I can resolve the name of the
enumeration and its values.
The following code demonstrates the problem:
#include <db_RO.hpp>
/*
namespace graphics { enum db_status { FROM_FILE, FROM_DB, FROM_NOWHERE }; };
// actually defined in db_RO.hpp
*/
int main(int argc,char **argv) {
char ofile[255];
strcpy(ofile,"organ.cdbf");
if (argc>1) strcpy(ofile,argv[1]);
// scenario 1: DOES NOT WORK
graphics::db_RO thedb;
// next line generates "error: `FROM_DB' undeclared"
if (thedb.load(ofile)==graphics::db_status(FROM_DB))
thedb.save(ofile);
// scenario 2: DOES WORK
using namespace graphics;
db_RO thedb;
// however next line works in this case, why???
if (thedb.load(ofile)==db_status(FROM_DB))
thedb.save(ofile);
return 0;
};
Only scenario 2 works. In if() of the first scenario it makes no
difference if I say graphics::db_status(FROM_DB) or just
db_status(FROM_DB). Both generate the listed error condition.
Why???
I'm using gcc 3.3. Is this a compiler specific bug or am I using it
improperly?
using its qualified name graphics::db_status(VALUE) it does not work.
If I say "using namespace graphics;" then I can resolve the name of the
enumeration and its values.
The following code demonstrates the problem:
#include <db_RO.hpp>
/*
namespace graphics { enum db_status { FROM_FILE, FROM_DB, FROM_NOWHERE }; };
// actually defined in db_RO.hpp
*/
int main(int argc,char **argv) {
char ofile[255];
strcpy(ofile,"organ.cdbf");
if (argc>1) strcpy(ofile,argv[1]);
// scenario 1: DOES NOT WORK
graphics::db_RO thedb;
// next line generates "error: `FROM_DB' undeclared"
if (thedb.load(ofile)==graphics::db_status(FROM_DB))
thedb.save(ofile);
// scenario 2: DOES WORK
using namespace graphics;
db_RO thedb;
// however next line works in this case, why???
if (thedb.load(ofile)==db_status(FROM_DB))
thedb.save(ofile);
return 0;
};
Only scenario 2 works. In if() of the first scenario it makes no
difference if I say graphics::db_status(FROM_DB) or just
db_status(FROM_DB). Both generate the listed error condition.
Why???
I'm using gcc 3.3. Is this a compiler specific bug or am I using it
improperly?