I have a library that is abstracted and basically looks like this:
A.h
namespace N {
class A
}
B.h
#pragma once
#ifndef B
#define B
#include "A.h"
namespace N {
class B: Public A
}
#endif
And the library is referenced in the CMakelists.txt like this:
global_add_library(libN A.cpp B.cpp)
target_link_libraries(libN someLibraries)
Now I have the main file which looks like this:
#include <libN/A.h>
#include <libN/B.h>
N::A a* = new A();
N::B b* = new B();
And its CMakelists.txt looks like this:
global_add_exectubale(application somemainccpfiles.cpp)
target_link_libraries(application libN)
What i am getting is an error saying
error: ISO C++ forbids deceleration of 'B' with no type.
So i am thinking that the B.h file isnt included properly? But why when the deceleration of A is just fine?
Any ideas?
EDIT: So I found out what the original problem was, the combination of the pragma once and the ifndef meant it wasn’t compiling properly. When I removed the pragma once it was fixed. But now the question is why is that? Shouldn’t it have worked even with both?
Your included “A.h” but in other file it was “libN/A.h”