I'm new to C and stuck on this. The answer here seems widely accepted, but I believe I'm following the correct format and still getting issues.
Here's the offending line in main() (in main.c)
PrintWrapper(PrintFunction, *decoded); // *decoded is a char
The PrintFunction (also in main.c):
void PrintFunction(char c)
{
printf("%c", c);
}
And the prototype declaration (in p1a2.h - in the same directory as main.c)
extern void PrintWrapper(void (*)(char), char c);
The actual source is hidden away in printwrapper.o (same directory as main.c). This is for an assignment and is a very contrived usage of passing a function as a parameter. I compile the program with
g++ main.c printwrapper.o -Wall -g -o tnine
and get the compiler error (the backtick is not a typo if that is relevant)
<path>/main.c:42: undefined reference to `PrintWrapper(void (*)(char), char'
Why does this happen? I'm hoping it's me overlooking something simple.