code::blocks workspace and projects

I'm a code::blocks user, so I've created the workspace and project files needed to compile Box2D in c::b, using MinGW GCC.

A few small changes had to be made to the source code make it possible and I hope these changes can be made to the distribution.

1. USHRT_MAX is not defined in GCC for some reason. Would it be possible to make your own define or just replace it with 0xFFFF?
2. sprintf_s() is Microsoft specific, as such it has no cross platform support for the TestBed project. Could it be replaced with something else, like snprintf() or perhaps a define macro? (#ifndef sprintf_s #define sprintf_s snprintf #endif)

I've attached an SVN patch that creates the necessary files and makes the changes that need to be made.

I hope you guys find this useful and that perhaps it will make it to the official distribution.
Thanks, I'll add the project to a new contrib folder.
About USHRT_MAX, I'm using Eclipse CDT with MinGW and I only have to #include <limits.h> in the b2PairManager.h file for it to compile. I'm just using the Engine folder, don't know about the testbed part...
Wahooney,

Would it be possible to put the code::blocks project files all into a separate directory?

I'm thinking:

Box2D/Contrib/CodeBlocks

BTW, I added <limits.h> as needed.
Hello,

Since this is my first post I'd like to start by thanking Erin for a robust and easy to use library - fantastic work!

With regard to the OP, a contrib folder is a great idea but may I suggest a slightly different location for the C::B or indeed any other contributed project files (including the original VC8)- namely a build/project directory.

Something along the lines of:

Box2d/Build/VC8
Box2d/Build/CodeBlocks
Box2d/Build/Eclipse

Also would it be possible to bring the project closer to the widely used include/lib directory paradigm:

Box2D/Include
Box2D/Lib

This should allow users to simply use the appropriate workspace to build the library, link to the results and get on with putting Box2D to good (or bad 😛 ) use.

I know it's somewhat cheeky to ask but I think this sort of change is easier to implement while the user base is not that large - yet 😉
I'll organise everything in the code::blocks project files into nix_BB's suggested structure if you like it, Erin.

Edit:
I just found another change that needs to be made!

In testbed/framework/test.h
friend JointCallback
needs to be changed to
friend class JointCallback

GCC doesn't seem to like the other way.
Yeah, I agree with nix_bb's layout. I'll put it on the TODO list.

Do you have anymore suggestions about source layout? Testbed/Helloworld layout?
Perhaps they should be grouped together into an examples folder? Leaving you with a tidier and more intuitive root:

Box2D\Documentation
Box2D\Engine
Box2D\Examples
Box2D\Include
Box2D\Lib
Box2D\Licence.txt
Box2D\Readme.txt
Box2D\TODO.txt

Looking at it like this suggests to me that 'Engine' might be more descriptive as 'Source'. I suppose the Build folder could reside in the root or fall under Engine and the Contrib folder could reside in Examples? Beyond that the internals won't really matter all that much once the Include/Lib structure is adopted.

I notice that renaming engine.lib to box2d.lib is listed under Version 1.3.0 but code layout (which I'm assuming involves the changes discussed in this thread) is listed under 1.2.0. They would seem to be part of the same process though.

😁 Too much of cheekiness!
Just something I found while making the projects and workspaces for Code::Blocks under the new layout...

There is an inconsistency in your includes in b2NullContact.h:
#include "../common/b2Math.h"
should be
#include "../source/common/b2Math.h"
(this has been fixed in the attached patch 😁 )

There are still an awful lot of warnings, including:
  • a hell of a lot of "newline at end of file"
  • some "signed/unsigned integer comparisons"
  • some depreciated iostream warnings
  • a few unused variables
  • a few switch warnings

I'd be happy to create a patch to fix these issues 🙂
Thanks Wahooney. I applied your patch and commited.

The include should actually be:

#include "../../Common/b2Math.h"

Stuff in the Source directory doesn't know it's in the Source directory.

I'm really surprised that VC8 lets so much bad stuff happen. I think I'll compile with Level 4 warnings. After I fix that stuff, I'd be happy to get a patch for the rest.

Original thread: https://box2d.org/forum/viewtopic.php?t=23