I have a suggestion regarding logging macros definitions from 
`nimble/host/include/host/ble_hs_log.h`.

Currently there are defined as follows:
```
#define BLE_HS_LOG(lvl, ...) \
    MODLOG_ ## lvl(LOG_MODULE_NIMBLE_HOST, __VA_ARGS__)

#define BLE_HS_LOG_ADDR(lvl, addr)                      \
    BLE_HS_LOG(lvl, "%02x:%02x:%02x:%02x:%02x:%02x",    \
               (addr)[5], (addr)[4], (addr)[3],         \
               (addr)[2], (addr)[1], (addr)[0])
```

The problem I encountered when porting mynewt-nimble to a new platform is that 
`lvl` argument of the `BLE_HS_LOG_ADDR` is prescanned. Very often external code 
uses the `DEBUG` macro (e.g. setting it to 1 or 0) and as a result nimble fails 
to compile.

Do you think it would be beneficial to change the `BLE_HS_LOG_ADDR` definition 
to avoid `lvl` argument expansion? For example, although a bit more verbose, it 
could be defined as  

```
#define BLE_HS_LOG_ADDR(lvl, addr)                      \
    MODLOG_ ## lvl(LOG_MODULE_NIMBLE_HOST,              \
                   "%02x:%02x:%02x:%02x:%02x:%02x",     \
                   (addr)[5], (addr)[4], (addr)[3],     \
                   (addr)[2], (addr)[1], (addr)[0])
```

[ Full content available at: https://github.com/apache/mynewt-nimble/issues/188 
]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to