When I learned the C language singly linked list, I encountered this error message "Linker tool error LNK2019", so I thought why this is caused? At first I thought it was a global variable that was not defined by me, but in my test, only my singly linked list code can reproduce the error, and it can’t even generate an exe. Therefore, I want to ask why this occurs. This question (is it related to the compilation process of vs2019)
My questions:I was deliberately letting the function named "fake" not be defined. I wanted to reproduce this error, so I didn’t define the function in other codes, but they reported different error messages directly. What I’m curious about is that vs. When compiling the source code into an obj file, what happened to make it appear this error.
#include <stdio.h>
#include <stdlib.h>
typedef struct Link {
int elem;
struct Link* next;
}link;
link* initLink();
void fake(link* p);
int main() {
printf("test:\n");
link* p = initLink();
fake(p);
return 0;
}
link* initLink() {
link* p = NULL;
link* temp = (link*)malloc(sizeof(link));
temp->elem = 1;
temp->next = NULL;
p = temp;
for (int i = 2; i < 5; i++) {
link* a = (link*)malloc(sizeof(link));
a->elem = i;
a->next = NULL;
temp->next = a;
temp = temp->next;
}
return p;
}
At this time it did not appear an error like LINK2019:
#include <stdio.h>
void display();
int main()
{ printf("test:\n");
int* p = NULL;
display(p); //At this time it did not appear an error like LINK2019
return 0; }
Instead, this error message appears" Error C2660 "display": Function does not accept 1 parameter"