C에서 전역 유니온을 선언하는 방법을 잘 모르겠습니다. 아래 코드는 모두 주 외부에 있습니다.C에서 전역 유니온 선언
test.c:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘find’.
어떻게 내가 함수에 대한 반환 형식으로 사용할 수있는 방식으로 노동 조합을 선언 할 수 있습니다 :이
typedef union{
int iVal;
char* cVal;
} DictVal;
struct DictEntry{
struct DictEntry* next;
char* key;
DictVal val;
int cTag;
};
DictVal find(char* key);
int main()
{
struct DictEntry dictionary[101];
//printf("Hello");
}
DictValue find(char* key)
{
DictVal a;
a.iVal = 3;
return a;
}
, 나는 오류가 나타납니다?
미리 감사드립니다. 앤드류
읽지 말아야 할 내용 typedef union DictVal { int iVal; char * cVal; } DictVal; ? – blueberryfields
정말요? 그 발췌문만으로도 잘 컴파일됩니다. – ephemient
@blueberryfields - 아니, 그냥 익명의 조합인데 'typedef'라는 이름이 붙어 있습니다. –