Home > Enterprise >  C Define macro with "or" operator confusion
C Define macro with "or" operator confusion

Time:04-01

Confused here

https://android.googlesource.com/platform/external/sonivox/ /refs/tags/android-12.1.0_r2/arm-wt-22k/lib_src/eas_wtengine.c#168

#if !defined(NATIVE_EAS_KERNEL) || defined(_16_BIT_SAMPLES)

Seems like on arm it will be defined, see here

https://android.googlesource.com/platform/external/sonivox/ /refs/tags/android-12.1.0_r2/arm-wt-22k/Android.bp#121

But all builds have

https://android.googlesource.com/platform/external/sonivox/ /refs/tags/android-12.1.0_r2/arm-wt-22k/Android.bp#66

So it should be true on both arm and other i.e x86_64, right?

It will be only not defined when frist condition is not met and the 2nd, meaning no EAS_NATIVE_KERNEL flag and no _16_BIT_SAMPLES flag?

CodePudding user response:

!defined(NATIVE_EAS_KERNEL) || defined(_16_BIT_SAMPLES) will only be false when NATIVE_EAS_KERNEL is defined and _16_BIT_SAMPLES isn't defined (when defined(NATIVE_EAS_KERNEL) && !defined(_16_BIT_SAMPLES) is true).

NATIVE_EAS_KERNEL _16_BIT_SAMPLES !defined(NATIVE_EAS_KERNEL) || defined(_16_BIT_SAMPLES)
Not defined Not defined True
Not defined Defined True
Defined Not defined False
Defined Defined True
  • Related