문제

#define GETSTRING(s) return #s

enum a_type { SMALL, MEDIUM, LARGE };

const char* get_data(a_type a) { return GETSTRING(a); }


int main() {

   a_type at = SMALL;

   const char* s = get_data(at);

   return 0;
}

I get compiler error:

main.cpp(5) : error C2059: syntax error : 'return'

What have I done wrong?

도움이 되었습니까?

해결책

If you use gcc -E to output the preprocessed source, you'll see you have an extra return in get_data :

const char* get_data(a_type a) { return return "a"; }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top