Ad

C Define Macro With "or" Operator Confusion

- 1 answer

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?

Ad

Answer

!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 definedNot definedTrue
Not definedDefinedTrue
DefinedNot definedFalse
DefinedDefinedTrue
Ad
source: stackoverflow.com
Ad