janwas Posted October 16, 2011 Report Share Posted October 16, 2011 We have two macros for annotating code and preventing unused argument/variable warnings.void Function(int argument1, float UNUSED(argument2)){ ASSERT(argument1 == 0); UNUSED2(argument1);}The first argument is used only in debug mode, so we need UNUSED2 to suppress the warning.I never did like that name for the macro, but UNUSED_VARIABLE is a bit too long, and namingUNUSED differently would be even worse in that regard, because it sometimes occurs several times in parameter lists.I just had a simple idea - how about replacing UNUSED() with a C-style comment: float /*argument2*/ ?That shortens the parameter list and leaves the UNUSED name for the current UNUSED2.Any objections or suggestions for further improvement? Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted October 16, 2011 Report Share Posted October 16, 2011 The macro is valuable for Doxygen - we run it with PREDEFINED = "UNUSED(x)=x" so that it knows the names of the unused parameters, and I think using comments would break that.(Also I think using comments is more ugly than the current macros, but that's not a particularly technical argument ) Quote Link to comment Share on other sites More sharing options...
janwas Posted October 16, 2011 Author Report Share Posted October 16, 2011 That's a very good point. I don't see a way to get commented-out names into Doxygen.There are not THAT many unused parameters, but I agree they should be mentioned in Doxygen.The commenting-out idea is dead in the water as far as I'm concerned.Any ideas for better (but still short) names for the macros? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.