void casting parameters never used

Post Reply
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

void casting parameters never used

Post by gdlk »

Hi!

I was reading the code of the btRaycastVehicle, and sometimes I see a void cast over a parameter and the parameter is never used in the method where that happens. For example, in updateSuspension, the deltaTime parameter is casted and never used:

Code: Select all

void	btRaycastVehicle::updateSuspension(btScalar deltaTime)
{
	(void)deltaTime; 
        ...
}
Why is this done? Is there a hidden utility on that? (the only reason I can think is to evade compiler warnings, but maybe there is more...)

Thanks!!
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: void casting parameters never used

Post by Flix »

Hehe :) ...

Lines like that are commonly used in C++ to remove possible compilation warnings caused by the fact that a method parameter is never used inside the method's scope.

I don't know if that's the case here: many times programmers start adding those lines, then they actually use those variables inside the method's scope and then forget to remove these kind of "hacks"...

So you've guessed it right :D
gdlk
Posts: 62
Joined: Fri Oct 24, 2014 7:01 pm

Re: void casting parameters never used

Post by gdlk »

great!

Thank you!! =D
Post Reply