I realize this has been asked many times, but none of the solutions worked. Here is a simple test code I have.
test.h
#ifdef TEST_H
#define TEST_H
int return_int_3();
#endif
test.c
#include "test.h"
int return_int_3() {
return 3;
}
main.c
#include "test.h"
#include <stdio.h>
int main(void) {
printf("%d", return_int_3());
return 0;
}
I don't see what is wrong. One solution was that you have to put the include of "test.h" at the very top which I've done. Other solutions are saying that you have to declare the function before main before using it, which I assume the #include takes care of. So, I'm confused on what the problem is. It does work and produces the right output, but what is the correct way to solve this? I'm using gcc version 10.1.0 if that helps. Thanks.