#include <stdio.h>
#include <stdbool.h>
int SmallerOf(int x, int y);
void TestCase(void)
{
int x, y, actual;
x = 3;
y = 4;
actual = 3;
int expected = SmallerOf(x, y);
if (actual == expected)
{
printf("PASS");
}
else
{
printf("FAIL");
}
}
Having an error with linker having a linker error message 2019. I tried to see if my linker under properties looking at something different or a certain file. It seems like everything is good and I a just look. What could be the cause of this when I haven't touched the linker directories? thank you
I have looked at properties and it seems to be fine and not sure what this error message means.
CodePudding user response:
This is a (forward) declaration of a function:
int SmallerOf(int x, int y);
It makes a promise to the compiler that there will be a definition of the function later, so the compiler will not complain when you call it in your code - even if the compiler have even not seen the actual function definition yet.
When linking your final program, it will however not find this definition, hence you get a linker error. In order to fix the problem, provide a definition of the function too. Example:
int SmallerOf(int x, int y) {
return x < y ? x : y;
}
Your final program also needs a definition of the int main(void)
or int main(int, char**)
function in order to know where to start execution of the program.