I'm trying to put a few function pointers in a header file so that I can use those function pointers as any other function by including the header file. The first problem was that than of-course you get linking errors because everywhere you include that header file you create a new definition of a global variable. So I gave the function pointers a static variable and it seemed to compile fine, my problem now however is that after I assign the appropriate functions (loaded from a dll file) to those pointers in one function, they don't seem to have changed for another function.
I'm bedazzled! Anyone has an idea?
I can't use definitions because the pointers need to be get- and set-able.
I'll try to make them extern like you said, I don't exactly what it means yet because I never had to deal with it, but I know it is something like showing the compiler it defined outside it's source, or something. :P
The pointers don't need to be initialized to a specific value, once I assign them a value, they will be either 0 or a valid pointer.
Computergeek01, I know what you mean but that's not my problem. Try to create a header (with preprocessor protection of-course) with a few global variables and include them in a few source files and see what happens.
static variables in the global scope make them local to the file they are in. This is also a deprecated construct anyway, you should use unnamed namespaces if you want that effect.
But anyway, as you found out, you need to extern them and define them wherever.