Jump to content
  • Advertisement
Sign in to follow this  
overeasy

Namespaces & Static Libs

This topic is 2822 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
Advertisement
When you define your Vector2 do it like this

namespace MyNamespace
{
class Vector2
{
}
}

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

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
It is the only way to do this. You can open a namespace many times, unlike a class which can only de defined once.

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 within 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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!