Why do (1 && !A) in c++ pre-processor

Viewed 136

In some C++ file, I found:

#ifndef UE_WITH_CHEAT_MANAGER
#define UE_WITH_CHEAT_MANAGER (1 && !UE_BUILD_SHIPPING)
#endif

Comming from CheatManager.h.

What is the difference with:

#ifndef UE_WITH_CHEAT_MANAGER
#define UE_WITH_CHEAT_MANAGER (!UE_BUILD_SHIPPING)
#endif

Is it in order to prevent warnings on some specific compiler?

Additional info:

  • UE_BUILD_SHIPPING is 0 by default and is set to 1 for shipping builds (builds that are distributed to consumers/players).
  • UE_WITH_CHEAT_MANAGER is used to exclude some part of the code from compilation.

(Edited to answer requests in comments.)

1 Answers

Nobody is perfect, not even the authors of the Unreal Engine.

Setting aside any possibility of operator overloading, the type and values of the two expressions are identical. I suspect (and it's only a hunch), that the author is forgetting that the type of (!B) is a bool in C++.

(1 && !B) is more explicitly perhaps a bool type as it contains the && operator.

Related