I am migrating my project to C++. Everything in the SDK works so far except NRF_BLE_GATT_DEF(). This returns the error C++ requires a type specifier for all declarations. Is there a workaround?
I am migrating my project to C++. Everything in the SDK works so far except NRF_BLE_GATT_DEF(). This returns the error C++ requires a type specifier for all declarations. Is there a workaround?
Hi,
Which example are you trying to convert to C++.? Also, which compiler are you using.?
Regards,
Swathy
SDK 16.0 using usb_cdc_acm example. GCC with -std=C++11.
My workaround so far has been to place the above definition and callback function in a C module and to pass the arguments to the real callback in the C++ module.
Also, when including app_usbd_cdc_acm.h in the C++ module it complained about a forward enum declaration. I had to move the enum declaration into the app_usbd_cdc_acm_internal.h file and protect it with a #define:
#ifndef _APP_USBD_CDC_
#define _APP_USBD_CDC_
typedef enum app_usbd_cdc_acm_user_event_e {
APP_USBD_CDC_ACM_USER_EVT_RX_DONE, /**< User event RX_DONE. */
APP_USBD_CDC_ACM_USER_EVT_TX_DONE, /**< User event TX_DONE. */
APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN, /**< User event PORT_OPEN. */
APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE, /**< User event PORT_CLOSE. */
} app_usbd_cdc_acm_user_event_t;
#endif // !_APP_USBD_CDC_
/*lint -save -e165*/
/**
* @brief Forward declaration of @ref app_usbd_cdc_acm_user_event_e.
*
*/
enum app_usbd_cdc_acm_user_event_e;
SDK 16.0 using usb_cdc_acm example. GCC with -std=C++11.
My workaround so far has been to place the above definition and callback function in a C module and to pass the arguments to the real callback in the C++ module.
Also, when including app_usbd_cdc_acm.h in the C++ module it complained about a forward enum declaration. I had to move the enum declaration into the app_usbd_cdc_acm_internal.h file and protect it with a #define:
#ifndef _APP_USBD_CDC_
#define _APP_USBD_CDC_
typedef enum app_usbd_cdc_acm_user_event_e {
APP_USBD_CDC_ACM_USER_EVT_RX_DONE, /**< User event RX_DONE. */
APP_USBD_CDC_ACM_USER_EVT_TX_DONE, /**< User event TX_DONE. */
APP_USBD_CDC_ACM_USER_EVT_PORT_OPEN, /**< User event PORT_OPEN. */
APP_USBD_CDC_ACM_USER_EVT_PORT_CLOSE, /**< User event PORT_CLOSE. */
} app_usbd_cdc_acm_user_event_t;
#endif // !_APP_USBD_CDC_
/*lint -save -e165*/
/**
* @brief Forward declaration of @ref app_usbd_cdc_acm_user_event_e.
*
*/
enum app_usbd_cdc_acm_user_event_e;