Skip to content

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

@pabloandresm

Description

@pabloandresm

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions