ZTat
2008-07-04 07:18:50 UTC
Here are the details of the files in my project:
obj.cpp:
#include "obj.h"
obj::obj(){
}
obj::~obj(){
}
obj.h:
#ifndef OBJ_H
#define OBJ_H
#include "library.h"
class obj{
...
};
#endif
main.cpp:
#include "myobj/obj.h"
int main(void){
obj myObject;
myObject.DoSomething();
}
library.h:
#ifndef LIB_H
#define LIB_H
...
#endif
The errors I get are 'multiple definition' errors.
It looks like when compiling/linking the preprocessor includes "library.h" twice, although I am using a #ifndef directive before. I've read that C++ compiles each object main.cpp and obj.cpp without passing #define between the two and thats why the #ifndef doesn't work.
Any help will be appreciated.