c - If an enum is declared in a function, what is the scope? -


is enum private function?

void dosomething() {    enum cmds {       a, b, c    } } 

the enum cmds type , enumeration members a, b, , c, local function scope.

note while enumerations don't introduce new scope member constants, scoped within containing scope, in case function body.

int dosomething(void) {     enum cmds {         a, b, c  // 0, 1, 2     };      return c;  // returns 2 }  int anotherthing(void) {     enum cmds {         c, d, e  // 0, 1, 2     };     return c;  // returns 0 } 

run example code here on coliru


Comments