Box2D Forums

It is currently Thu Oct 02, 2014 9:27 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun Dec 07, 2008 5:44 pm 
Offline

Joined: Sun Dec 07, 2008 5:34 pm
Posts: 6
Hi,

I would like to suggest encapsulating Box2D in a namespace, such as "b2".
Along with the advantages of encapsulation, it would also make things easier for people using IDEs with code completion.


Thank you for making this wonderful software!


Top
 Profile  
 
PostPosted: Mon Dec 08, 2008 8:18 am 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
Great suggestion, model76. In fact, we've already included this in the trunk. The next release ought to have all m_variables stores in the Box2D.Common.b2internal namespace.


Top
 Profile  
 
PostPosted: Mon Dec 08, 2008 11:40 am 
Offline

Joined: Sun Jan 20, 2008 7:52 pm
Posts: 434
The ActionScript version uses namespaces, yes. Were you asking about the C++ version?


Top
 Profile  
 
PostPosted: Mon Dec 08, 2008 11:55 am 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
Yes, I'm being presumptive, sorry. I guess I was thinking of the variable name issue, and Box2D has fixed that already in v2.0.1, so that didn't make sense.


Top
 Profile  
 
PostPosted: Mon Dec 08, 2008 2:54 pm 
Offline

Joined: Sun Dec 07, 2008 5:34 pm
Posts: 6
I meant the C++ version, yes. -Sorry for the confusion :)


Top
 Profile  
 
PostPosted: Mon Dec 08, 2008 4:19 pm 
Offline

Joined: Mon Jan 07, 2008 10:51 am
Posts: 1911
Nono, my fault. I don't really do C++ well enough to answer your (now clarified) question, though.


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 11:07 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2946
I wrote the C++ version to work with poor C++ compilers where namespace support can be spotty. Also, in my experience most game programmers don't use C++ namespaces.


Top
 Profile  
 
PostPosted: Wed Dec 10, 2008 2:00 pm 
Offline

Joined: Sun Dec 07, 2008 5:34 pm
Posts: 6
Erin Catto wrote:
Also, in my experience most game programmers don't use C++ namespaces.

Really? Too bad for them! Namespaces ROCK! :D
I certainly wouldn't want to be without them.

Anyway, I see your point about shady compilers, as compatibility rocks even more than namespaces. It would be a shame to leave out exotic platforms, such as mobile phones, drawing pads, refrigerators, and intelligent hairdryers, and what not.

Keep up the good work!


Top
 Profile  
 
PostPosted: Thu Dec 25, 2008 5:29 pm 
Offline

Joined: Thu Dec 25, 2008 5:25 pm
Posts: 2
Erin Catto wrote:
I wrote the C++ version to work with poor C++ compilers where namespace support can be spotty. Also, in my experience most game programmers don't use C++ namespaces.


It shouldn't be unreasonable to conditionalize the use of namespaces, although it'd probably make for redundant references (i.e. "b2::b2World").

Internally, there's a "struct Point" that conflicted with Mac OS X headers' Point.

I'd love to see it all in a namespace. Are there really that many compilers in use today for Box2D projects that also don't understand namespaces?


Top
 Profile  
 
PostPosted: Sun Jan 18, 2009 11:54 am 
Offline

Joined: Fri Dec 14, 2007 9:19 pm
Posts: 100
Well, it's relatively easy to wrap it all in a namespace for your own project.

Just make this file:
Code:
namespace box2d {
#include "Box2D.h"
}


Are there really compilers these days that don't do namespaces well? Do people still use them? I think it makes a lot of sense for C++ libraries to live within a namespace.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group