edit: Also afaik include guards only help in case of two classes which have the same name, but not if there are two files with the same name. I used them already. |
That's exactly the
opposite of what they're usually used for. As generally used, they stop you including the exact same file twice. I have never seen them applied to individual classes, although there's no reason you couldn't do that.
I thought your problem was that every time your preprocessor goes looking for the file named a.h, it will find one of them first and use that one every time. Linkers do not link to *.h files - they link to compiled object files. Your *.h files are included by the preprocessor, before compilation.
@Moschops: I don't include them in the same file. |
The preprocessor doesn't care what file you include them in; it will follow the same search pattern and find the same one every time. If you can't rename one, then moving it off the search path and then adding the path to the front of its name when you include it will ensure that you can specify which one is being included. It's actually quite common; for example, I often see this sort of thing:
#include <OpenGL/OpenGL.h>
where all the header files for a particular library are tucked away together in a subdirectory off the principal search path.
This functionality is stored in a class which has the same name in both libraries. |
So your problem isn't just that you've got two header files with the same name, which is easily dealt with. You've got two classes with the exact same name? Presumably, that won't compile as it will look like a class redefinition. You could get round that with namespaces.
Duoas, you're typing. Not speaking. You don't have to write down exactly what you would say if this were spoken conversation. You can leave out the filler words and mumbling. :)