Namespace x has no member y | Adding namespaces to existing project

Dec 2, 2017 at 4:37pm
Hello!

I need help :< I have an existing project which worked fine until I decided to isolate a module and add it into its own namespace. Situation looks a bit like this:

File a.h:
1
2
3
4
5
namespace n {
    struct a {
        //stuff...
    };
}


File b.h:
1
2
3
4
5
6
7
8
#include "a.h"
namespace n {
    class b {
    public:
        void foo(const n::a& a1);
/* Here both GCC and intellisense agree that namespace n has no member a. Without n:: GCC says a is undefined. */
    };
}


Is it possible or is there magic going inside my includes? It's my first time creating my own namespaces so I might be missing something obvious... all ideas welcome. Thanks!
Last edited on Dec 2, 2017 at 4:38pm
Dec 2, 2017 at 5:44pm
The code you have posted works perfectly fine. There must be something that you’re not showing us.
Dec 2, 2017 at 9:01pm
Thanks, found the problem. Turned out that it was with the additional headers for inline functions in another file.

Before:
1
2
3
4
namespace n {
    //stuff
}
#include "inlines.hpp" 


After:
1
2
3
4
namespace n {
    //stuff
#include "inlines.hpp"
}


It compiles!
Topic archived. No new replies allowed.