I am getting a funky multiple definition error. The include structure is as follows:
MAIN -> VM -> BACKEND
Main includes vm which includes backend.
I have three global char *
pointers in backend, and it is the members that I get the multiple definition errors.
I get multiple definitions in vm.cpp
, main.cpp
and moc_vm.cpp
(I use Qt).
I tried declaring the pointers as external in the rest of the sources, but it didn't help. All preprocessor guards are in place, and I don't know why I am getting the error, since they are obviously defined in only one place...
Any ideas?
EDIT: This is strange, I can include BACKEND into MAIN and there are no problems, only when the chain is MAIN>VM>BACKEND I get the errors.
Define them as external in the header file. Define them (not as external) once in a single cpp file.
You should be safe.