Using the MDF with C++

ESP_Bond
Posts: 51
Joined: Mon Apr 15, 2019 1:37 pm

Re: Using the MDF with C++

Postby ESP_Bond » Fri Jul 12, 2019 3:12 am

C++ does not support automatic void type conversion, so you need to add a cast before MDF_XALLOC,
for example: char *data = (char *)MDF_MALLOC(MWIFI_PAYLOAD_LEN);

danylook
Posts: 7
Joined: Thu Aug 30, 2018 3:34 pm

Re: Using the MDF with C++

Postby danylook » Fri Jul 12, 2019 2:51 pm

hi
thanks so much for your help
the error change to


/home/cowscan/esp/esp-mdf/components/mcommon/include/mdf_mem.h:80:26: error: pointer targets in initialization differ in signedness [-Werror=pointer-sign]
#define MDF_MALLOC(size) ({ \

i try with char, unsigned char and signed char

#define MDF_MALLOC(size) ({ \
unsigned char *ptr = ( unsigned char *)malloc(size); \
if(!ptr) { \
MDF_LOGE("<ESP_ERR_NO_MEM> Malloc size: %d, ptr: %p, heap free: %d", (int)size, ptr, esp_get_free_heap_size()); \
assert(ptr); \
} \
if (MDF_MEM_DEBUG) { \
mdf_mem_add_record(ptr, size, TAG, __LINE__); \
} \
ptr; \
})

ESP_Bond
Posts: 51
Joined: Mon Apr 15, 2019 1:37 pm

Re: Using the MDF with C++

Postby ESP_Bond » Thu Jul 18, 2019 9:25 am

You don't need to modify esp-mdf, you just need to add a type cast before MALLOC, please refer to: get_start.cpp
Attachments
get_started.cpp
(8.26 KiB) Downloaded 652 times

Who is online

Users browsing this forum: No registered users and 25 guests