senoutouya / recastnavigation

Automatically exported from code.google.com/p/recastnavigation
zlib License
0 stars 0 forks source link

GCC compiler warnings #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There are a few GCC compiler warnings in Detour (possibly other places too
but I'm only looking at Detour).

One that crops up a lot and is easily fixed is salt in dtMeshTile is an int
but everywhere else it's treated as an unsigned int. Changing the
dtMeshTile salt to unsigned int fixes that.

The other is trickier. This code:

static const int DT_NAVMESH_MAGIC = 'DNAV';

generates a multi-character character constant warning with GCC. I've read
that this isn't portable but it seems to have worked fine everywhere I
tried it. The only trouble is this is in a header, so in my case where we
have warnings as errors enabled including DetourNavMesh.h broke the build.

My fix for this was to do this:

#define DT_MAKE_MAGIC(magic) ((#magic[0] << 24) + (#magic[1] << 16) +
(#magic[2] << 8) + (#magic[3]))

static const int DT_NAVMESH_MAGIC = DT_MAKE_MAGIC(DNAV);

Kind of ugly but this appeared to work in MSVC and GCC. I feel like there
should be a better way but I haven't come up with one...

Original issue reported on code.google.com by cameron....@gmail.com on 3 Feb 2010 at 2:42

GoogleCodeExporter commented 9 years ago
Thanks, I'll change those asap. Any idea how to suppress/enable those warnings 
so I
can enable them on my xcode project? The GCC that ships with Xcode is less 
pedantic
about GCC warnings.

Original comment by memono...@gmail.com on 3 Feb 2010 at 2:41

GoogleCodeExporter commented 9 years ago
We're using -Wall.

Original comment by cameron....@gmail.com on 4 Feb 2010 at 12:54

GoogleCodeExporter commented 9 years ago
I could not trigger the multichar warning (tried -Wmultichar), but made simple 
fix
for it. Added -Wall to xcode compiler flags and the whole code now compiles 
fine with
those. Fixed in R120.

Original comment by memono...@gmail.com on 5 Feb 2010 at 8:02

GoogleCodeExporter commented 9 years ago
Strange, on Linux I'm not actually passing any warning flags and I'm getting the
multichar warnings. Maybe Apple have modified the gcc warning levels on Mac.

Original comment by cameron....@gmail.com on 14 Feb 2010 at 10:01

GoogleCodeExporter commented 9 years ago
By default xcode has quite a few warnings supressed. Using -Wall now and it 
seems to
catch many things that I have previously had to fix separately on VisualC too.

Original comment by memono...@gmail.com on 15 Feb 2010 at 7:27