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);
Using the MDF with C++
Re: Using the MDF with C++
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; \
})
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++
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 650 times
Who is online
Users browsing this forum: No registered users and 39 guests