当我有时间的时候,我已经自学了几个月的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)

最佳答案

因为在RastgeleKarakter.h中您声明
char RastgeleKarakterOlustur(const RastgeleKarakter);
RastgeleKarakter.c中定义
RastgeleKarakter RastgeleKarakterOlustur() {...}
它们的函数名相同,但签名不同。你可以考虑换一个。

关于c - 如何在C中解决此问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55641622/

10-11 16:21