typedef
calledで作成した型へのポインターをパラメーターとして受け取る関数を作成しようとしていますNodeType
。typedef
名前にリンケージがないことをぼんやりと理解しています。NodeType
型の両方のインスタンスが同じ翻訳単位にあるように見えるときに、次のエラーが発生する理由がわかりません。
コードは次のとおりです。
#include <stdio.h>
int main(){
typedef struct NodeTag{
char* Airport;
NodeTag * Link;
} NodeType;
//Declare print function
void printList(NodeType *);
void printList(NodeType * L){
//set N to point to the first element of L
NodeType * N = L;
//if the list is empty we want it to print ()
printf("( ");
//while we are not at the Link member of the last NodeType
while(N != NULL){
//get the Airport value printed
printf("%s", N->Airport);
//advance N
N= N->Link;
if(N != NULL){
printf(", ");
}
else{
//do nothing
}
}
printf(")");
}
return 0;
}
これは私が遭遇するエラーです:
linkedlists.c: In function 'int main()':
linkedlists.c: error: type 'NodeType {aka main()::NodeTag} with no linkage used
to declare function 'void printList(NodeType*) with linkage [-fpermissive]
ご協力いただきありがとうございます!