How to make application compile with different ESP-IDF versions

axellin
Posts: 197
Joined: Mon Sep 17, 2018 9:09 am

How to make application compile with different ESP-IDF versions

Postby axellin » Tue Nov 06, 2018 10:17 am

Hi,

My application can be compiled with current git master tree.
However, when I try to compile with v3.1.1 esp-idf, I got compile errors.

e.g.
In master tree:
struct gattc_search_cmpl_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
esp_service_source_t searched_service_source; /*!< The source of the service information */
} search_cmpl;

In v3.1.1:
struct gattc_search_cmpl_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
} search_cmpl;


So "searched_service_source" does not exist in v3.1.1.

I though something like below should work, but I don't find similar define for IDF_MAJOR_VER/IDF_MINOR_VER in esp-idf sdk.

Code: Select all

#if IDF_MAJOR_VER >= 3 && IDF_MINOR_VER >= 2
   // for the code compatible with git master..
#elif IDF_MAJOR_VER >= 3 && IDF_MINOR_VER >= 1
   // for the code compatible with v3.1
#else
   // for the code compatible with v3.0
#endif
I'm wondering what is the best way to add #if or #ifdef guard to the appliation code
to allow it to be compiled with different IDF versions?

Who is online

Users browsing this forum: No registered users and 108 guests