Problems with own namespace stat

H

Hansen

Hi Group,

I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called stat
from wchar.h that I'm refering to even though I've written
dao::stat::stat_base

I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.

#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs
{
stat_client.attach(this->impl_ptr());
}
}

I'm using visual C++ 2005 Express

Does anyone know what might be the problem and the solution?

/Hansen
 
F

Fei Liu

Hansen said:
Hi Group,

I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called stat
from wchar.h that I'm refering to even though I've written
dao::stat::stat_base

I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.

#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs
{
stat_client.attach(this->impl_ptr());
}
}

I'm using visual C++ 2005 Express

Does anyone know what might be the problem and the solution?

/Hansen
Post a complete compilable test code that demonstrates your problem, you
can check it against dinku or comeau to test it out.
 
H

Hansen

Fei Liu said:
Hansen said:
Hi Group,

I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called
stat from wchar.h that I'm refering to even though I've written
dao::stat::stat_base

I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.

#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs
{
stat_client.attach(this->impl_ptr());
}
}

I'm using visual C++ 2005 Express

Does anyone know what might be the problem and the solution?

/Hansen
Post a complete compilable test code that demonstrates your problem, you
can check it against dinku or comeau to test it out.

The code base is very large and complex - posting it here doesn't seem as an
option.
I've tested something else though. If I change the name of my namespace to
e.g. statistic it still isn't able to find it.
I'm pusled by this, since I have included my header file with the namespace
as posted above, and therefore thought it would be accesable.

/Hansen
 
G

Gavin Deane

Fei Liu said:
Hansen said:
Hi Group,
I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called
stat from wchar.h that I'm refering to even though I've written
dao::stat::stat_base
I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.
#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs
{
stat_client.attach(this->impl_ptr());
}
}
I'm using visual C++ 2005 Express
Does anyone know what might be the problem and the solution?
Post a complete compilable test code that demonstrates your problem, you
can check it against dinku or comeau to test it out.

The code base is very large and complex - posting it here doesn't seem as an
option.

Not the whole code base, just a minimal but complete program that
demonstrates your problem and nothing else, as per the FAQ guidelines:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8

See Thomas Tutone's post here for how and why

http://groups.google.co.uk/group/co...q=thomas+tutone&rnum=4&hl=en#8e0bb7ea8a166a57

Gavin Deane
 
M

Marcus Kwok

Hansen said:
Hi Group,

I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called stat
from wchar.h that I'm refering to even though I've written
dao::stat::stat_base

I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.

#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs
{
stat_client.attach(this->impl_ptr());
}
}

I'm using visual C++ 2005 Express

Does anyone know what might be the problem and the solution?

[OT] Check your setting for "Treat wchar_t as a native type":
http://msdn2.microsoft.com/en-us/library/dh8che7s.aspx

On Visual Studio .NET 2003, it defaulted to "off", but from what I see
they switched it in 2005, but it wouldn't hurt to check it anyway.
 
M

Matteo

Hi Group,

I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called stat
from wchar.h that I'm refering to even though I've written
dao::stat::stat_base

I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.

#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs

I might be wrong here, but since you are already in namespace dao,
won't the compiler look for stat_base in dao::dao::stat? Perhaps you
could fix it with:
void attach:):dao::stat::stat_base& stat_client)
^^---give a fully qualified name.

-matt
 
H

Hansen

Matteo said:
Hi Group,

I've made a statistic module for our framework, and have put it in a
namespace called stat (which resides in a namespace called dao)
My problem is that now the compiler thinks that it is the struct called
stat
from wchar.h that I'm refering to even though I've written
dao::stat::stat_base

I have included the stat_base.h header and have checked for using
statements, but nothing seems to work.

#include "dao/stat/stat_base.h"
namespace dao
{
[ ....]
void attach(dao::stat::stat_base& stat_client) <--- compiler barfs

I might be wrong here, but since you are already in namespace dao,
won't the compiler look for stat_base in dao::dao::stat? Perhaps you
could fix it with:
void attach:):dao::stat::stat_base& stat_client)
^^---give a fully qualified name.

I found out the problem was caused by cyclic including. Having terminated
the circle everything works fine.

/Hansen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top