swordlegend / recastnavigation

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

TODO: VC complains about unref formal variable, figure out a way to handle this better. #108

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
#define ForceUse(x) ((void)(x))

You could try using the above macro to satisfy VC

Original issue reported on code.google.com by armstron...@gmail.com on 23 Aug 2010 at 3:20

GoogleCodeExporter commented 9 years ago
Would that work in case of assert too? For example:

void rcWunderBar(const rcFoo* foo)
{
   RC_UNUSED(foo);
   rcAssert(foo);
   return RC_WUNDER;
}

Original comment by memono...@gmail.com on 23 Aug 2010 at 3:42

GoogleCodeExporter commented 9 years ago
Oh, and the point of that assert is that for the sake of integrity, I chose to 
make majority of the Recast interface to require the build context as 
parameter, and since it is a pointer, I use assert to make sure there is no 
programmer error there. 

Original comment by memono...@gmail.com on 23 Aug 2010 at 3:44

GoogleCodeExporter commented 9 years ago
Yeah - it'd work for the assert too. The code sample you've given is fine - 
that'd get rid of the compiler warning AND enable you to comment the assert 
back in. I use this technique a lot...because I quite often have a function 
param that is only used in debug.

Original comment by armstron...@gmail.com on 23 Aug 2010 at 4:12

GoogleCodeExporter commented 9 years ago
This works too:

void foo( Bar bar )
{
   bar; // Ignored
}

Eliminates the macro (and thus a code dependency, likely a header dependency). 
It's willful and explicit by comment. 

Original comment by copperp...@gmail.com on 28 Oct 2010 at 12:42

GoogleCodeExporter commented 9 years ago
How confident are you that that works on all compilers?

Original comment by armstron...@gmail.com on 28 Oct 2010 at 1:59

GoogleCodeExporter commented 9 years ago
Very...? Doesn't it guarantee a no-op?

Original comment by copperp...@gmail.com on 28 Oct 2010 at 4:40

GoogleCodeExporter commented 9 years ago
From: http://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/

template<class T> void ignore( const T& ) { }

Original comment by mends...@gmail.com on 30 Mar 2011 at 6:31