Sign in to follow this  

Namespaces & Static Libs

This topic is 2629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How to I package my entire static library in one namespace, to avoid conflicts between my Vector2 and Ogre's Vector2?

I want to be able to specify

MyNamespace::Vector2<float>(...);
Ogre::Vector2(...);

Share this post


Link to post
Share on other sites
Quote:
Original post by AndyEsser
When you define your Vector2 do it like this

namespace MyNamespace
{
class Vector2
{
}
}

That way you have to specify the namespace before each one.


Is it proper to do this for all the classes in the library using the same namespace?

Share this post


Link to post
Share on other sites
Quote:
Original post by rip-off
It is the only way to do this. You can open a namespace many times, unlike a class which can only de defined once.


I am now getting errors such as "argument Entity cannot be converted to type Game::Entity" where Game is the name of my namespace. I am getting these from classes [i]within[i] the namespace's classes.

I guess I'm asking if 'using namespace Game' is implicit within the different namespace definitions.

Went from compiling code to 200+ errors by changing my class Vector2d to Vector2 with namespaces o_O

Share this post


Link to post
Share on other sites
Quote:
Original post by no such user
That kind of thing can happen if you're inconsistent with defining things inside the namespace. Make sure that both your headers and source file contents are inside the namespace.


All my classes and implementations are now wrapped within namespace Game{} brackets, not including imports. Next possible reason?

Share this post


Link to post
Share on other sites
Quote:
Original post by overeasy
Quote:
Original post by no such user
That kind of thing can happen if you're inconsistent with defining things inside the namespace. Make sure that both your headers and source file contents are inside the namespace.


All my classes and implementations are now wrapped within namespace Game{} brackets, not including imports. Next possible reason?


As the old saying goes. There are only two things hard about programming: cache invalidation, naming things and off by one errors.
I would have to say using "Game" as a name is pretty poor.

Share this post


Link to post
Share on other sites
Quote:
Original post by CmpDev
Quote:
Original post by overeasy
Quote:
Original post by no such user
That kind of thing can happen if you're inconsistent with defining things inside the namespace. Make sure that both your headers and source file contents are inside the namespace.


All my classes and implementations are now wrapped within namespace Game{} brackets, not including imports. Next possible reason?


As the old saying goes. There are only two things hard about programming: cache invalidation, naming things and off by one errors.
I would have to say using "Game" as a name is pretty poor.


Sue me

Share this post


Link to post
Share on other sites

This topic is 2629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this