Hua.watson
9/25/2008 2:13:00 AM
On 9?24?, ??10?20?, Barry <dhb2...@gmail.com> wrote:
> On Sep 24, 7:35 pm, Hua.wat...@gmail.com wrote:
>
> > I want to add some declaration intio my namespace. But I do not have
> > the right to modify proto header files.
> > So I try
>
> > namespace mynamespace{
> > #include "a.h"
> > #include "b.h"
>
> > }
>
> > This is not a good style. But it even cannot work..... functions in
> > a.h has NOT been put into mynamespace....
>
> you need to put the definition into your namespace
>
> I guess you forgot to wrap your cxx files into you namespace
> suppose you have a.cpp for a.h
>
> remember to have header inclusion guard
> suppose A_H_INCLUDED for a.h
>
> so write your a_wrap.cpp like this:
>
> #include "a.h" // A_H_INCLUDED is defined
>
> namespace mynamespace {
> #include "a.cpp" // a.h in a.cpp will be discarded
>
> }
>
> HTH.
>
> --
> Best Regards
> Barry
Thanks, my code is like:
In global.h:
typedef int int32_t;
enum{ENUM_A};
In someone.h:
enum{ENUM_A};
In my.h:
namespace myspace{
#include "a.h"
}
In my.cpp
#include "global.h"
#include "someone.h"
myspace::int32_t ........
Then compiler tell me 2 error
1. ENUM_A conflict
2. int32_t is not in namespace myspace
In fact, I need include both global.h and someone.h to use some
functions, however, they defined some same unnamed enum. Now I have to
use 2 cpp file.....
Thanks