fteqw icon indicating copy to clipboard operation
fteqw copied to clipboard

QuakeC Order Of Operation Inquiry

Open Baker7 opened this issue 2 months ago • 1 comments

For the example ...

float does_focus_event_occur = KIsNotFocused(k) && Object_Will_Focus_Currently(k); // returns TRUE (?) when part 1 == TRUE and part 2 == FALSE

KIsNotFocused(k) is a macro with parenthesis around it and evaluates to true. Object_Will_Focus_Current(k) is a function and it is returning false

	float isnotfocused = KIsNotFocused(k); // TRUE
	float willfocus = Object_Will_Focus_Currently(k); // FALSE

So ( true ) && false is certainly false, right? ===> 0 && 1 == 0

Yet I get true!

isnotfocused == true willfocus == false does_focus_event_occur ( true? why?)

I don't get it. Even without short-circuiting -- which QuakeC doesn't have -- 0 & 1 is still zero.

Baker7 avatar Nov 17 '25 08:11 Baker7

I'm taking a guess here ...

I suspect combining a function return in an if statement with anything else is a "NO".

Baker7 avatar Nov 17 '25 09:11 Baker7