我有空的时候已经在教自己C了几个月,但遇到一个我不确定如何解决的问题。
具体来说,当我尝试使用gcc进行编译时,我得到:
RastgeleKarakter.c文件
RastgeleKarakter RastgeleKarakterOlustur(){
RastgeleKarakter this;
this=(RastgeleKarakter)malloc(sizeof(struct RASTGELEKARAKTER));
this->rnd=RandomKur();
this->TekKarakter=&TekKarakter;
this->FazlaKarakter=&FazlaKarakter;
this->AraKarakter=&AraKarakter;
this->Arama=&Arama;
this->BelirlenenKarakter=&BelirlenenKarakter;
return this;
}
void TekKarakter(){
int mod;
mod = (saniye()%52);
printf(Dizi[mod]);
printf('\n');
}
RastgeleKarakter.h文件
struct RASTGELEKARAKTER{
Random rnd;
char (*RastgeleKarakterOlustur)(struct RASTGELEKARAKTER*);
char (*TekKarakter)(struct RASTGELEKARAKTER*);
char* (*FazlaKarakter)(struct RASTGELEKARAKTER*, int);
char* (*AraKarakter)(struct RASTGELEKARAKTER*, char, char, int);
char (*Arama)(struct RASTGELEKARAKTER*, char[], char);
char* (*BelirlenenKarakter)(struct RASTGELEKARAKTER*, char, char, char, char, char, char, int);
};
typedef struct RASTGELEKARAKTER* RastgeleKarakter;
char RastgeleKarakterOlustur(const RastgeleKarakter);
char TekKarakter(const RastgeleKarakter);
char* FazlaKarakter(const RastgeleKarakter, int);
char* AraKarakter(const RastgeleKarakter, char, char, int);
char Arama(const RastgeleKarakter, char[], char);
char* BelirlenenKarakter(const RastgeleKarakter, char, char, char, char, char, char, int);
./src/RastgeleKarakter.c:26:21: error: conflicting types for 'RastgeleKarakterOlustur' RastgeleKarakter RastgeleKarakterOlustur() In file included from ./src/RastgeleKarakter.c:14:0: ./include/RastgeleKarakter.h:35:7: note: previous declaration of 'RastgeleKarakterOlustur' was here char RastgeleKarakterOlustur(const RastgeleKarakter); ./src/RastgeleKarakter.c:38:9: error: conflicting types for 'TekKarakter' void TekKarakter() In file included from ./src/RastgeleKarakter.c:14:0: ./include/RastgeleKarakter.h:36:7: note: previous declaration of 'TekKarakter' was here char TekKarakter(const RastgeleKarakter); ./src/RastgeleKarakter.c:49:9: error: conflicting types for 'FazlaKarakter' void FazlaKarakter(int Sayi) In file included from ./src/RastgeleKarakter.c:14:0: ./include/RastgeleKarakter.h:37:8: note: previous declaration of 'FazlaKarakter' was here char* FazlaKarakter(const RastgeleKarakter, int); ./src/RastgeleKarakter.c:62:9: error: conflicting types for 'AraKarakter' void AraKarakter(char a, char b, int Sayi)
答案 0 :(得分:2)
因为您在RastgeleKarakter.h
中声明
char RastgeleKarakterOlustur(const RastgeleKarakter);
并在RastgeleKarakter.c
中定义
RastgeleKarakter RastgeleKarakterOlustur() {...}
它们具有相同的功能名称,但具有不同的签名。您可以考虑更改其中之一。