NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

compilation error "operator '&&' has no right operand" and "#if with no expression"

Open pabloandresm opened this issue 5 months ago • 5 comments

Since version 2.3.1 I am receiving both errors described in the title multiple times. In my project I have "CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y" and "CONFIG_BT_NIMBLE_ROLE_BROADCASTER=n"

The nimconfig.h does this: / Cannot use server without advertise / #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) && !defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER) #define CONFIG_BT_NIMBLE_ROLE_BROADCASTER #endif

And in several parts of the code (like NimBLEAdvertisementData.cpp) you have things like this: #if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(DOXYGEN) ... #endif

...and the error appears in the second && complaining about CONFIG_BT_NIMBLE_ROLE_BROADCASTER with "operator '&&' has no right operand"

There are 2 possible solutions here:

  1. or either you do "#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER 1" instead of "#define CONFIG_BT_NIMBLE_ROLE_BROADCASTER" in the nimconfig.h
  2. or either you replace all appearances of "#if (CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_BROADCASTER && !CONFIG_BT_NIMBLE_EXT_ADV) || defined(DOXYGEN)" by using "defined(CONFIG_BT_NIMBLE_ROLE_BROADCASTER )" instead of plain "CONFIG_BT_NIMBLE_ROLE_BROADCASTER"

pabloandresm avatar Jun 11 '25 20:06 pabloandresm