Page 3 of 3

Re: Using the MDF with C++

Posted: Fri Jul 12, 2019 3:12 am
by ESP_Bond
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);

Re: Using the MDF with C++

Posted: Fri Jul 12, 2019 2:51 pm
by danylook
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; \
})

Re: Using the MDF with C++

Posted: Thu Jul 18, 2019 9:25 am
by ESP_Bond
You don't need to modify esp-mdf, you just need to add a type cast before MALLOC, please refer to: get_start.cpp