struct - Accessing enum Members in C -


i have function of type of struct, contains integers , reference enum, such:

typedef struct test {     error e;     int temp;     int value; }test; 

where enum is:

typedef enum error {     ioerror,     externalerror,     elseerror, }error; 

and have function wants return error (of enum of 3), depending on if happens.

where function of type test (i can't change types or values passed in),

why can't return error this? how go returning (i can't change struct definitions nor function prototypes).

test errorfunc() {      return test->e->ioerror; //gives error } 

any appreciated!

in c, code:

test errorfunc() {     return ioerror; } 

this c, in global namespace, there no "strong" enums , enum "members" "weakly typed integer constants". so, accessing "data member" of enum makes no sense. use constant.

compiler check if constant used of type return , complain if isn't. how complain depends on compiler, enums little strange weak type concent (stroustrup once called them "curiously half baked concept").


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -