header.h declares a function prototype void InitializeTestData();
a.c declares it void InitializeTestData() { ... }
b.c calls it InitializeTestData();
and the GCC linker reports b.c:108: undefined reference to '_InitializeTestData'
I must be overlooking something obvious, but what?
header.h does have an include guard (and its #define is used only in that file).
There are no other preprocessor directives involved … no #if wrapped around the prototype or declaration.
Without me having to post the whole project, can someone suggest something to make me say d'oh!?
Update: Netbeans handles it and has no problems with the dozen other files with external functions and data.
Answer: a.c was actually a NetBeans test file. NetBeans handles these differently from other files, since they each need to have an amain(). That means that they each have their own Makefile and b.o was not linking with a.o in that file. Solution, move the declaration to a file c.c which is not a Netbeans test file.
Are you linking
a.owithb.o? Most likely you aren’t.