I am trying to write a function that takes as a parameter a pointer to a type I created with a typedef called NodeType . I vaguely understand that typedef names have no binding. I'm not sure why I get the following error if both instances of type NodeType end up in the same translation unit.
Here is the code:
#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; }
This is the error I encountered:
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]
Thank you for your help!
source share