lwip macro name clashes

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

lwip macro name clashes

Postby permal » Wed Aug 16, 2017 8:20 pm

Hi,

I think I've seen this issued discussed briefly either here on the forum or on GitHub, but I can't find the post now so I'll ask again.

lwip defines a lot of macros with very general names such as connect, bind, send etc. in socket.h. These macros gives quite a few headaches since they clash with other code, both in the standard library and my own.

To handle these I've had to be very careful in what order files are included, but also do dirty tricks such as this:

Code: Select all

#undef write
#undef read
#undef bind
By changing the macros to inline functions these issues can be avoided with no additional overhead..

So by turning this

Code: Select all

#define read(s,mem,len)                           lwip_read_r(s,mem,len)
#define write(s,dataptr,len)                      lwip_write_r(s,dataptr,len)
into this

Code: Select all

inline int read(int s,void* mem, size_t len) {return  lwip_read_r(s,mem,len);}
inline int write(int s,const void* dataptr, size_t len) {return  lwip_write_r(s,dataptr,len); }
I believe a lot of us will be happier when using ESP-IDF with this change.

Thoughts? Comments?

Would this be welcome as a PR?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: lwip macro name clashes

Postby kolban » Thu Aug 17, 2017 1:00 am

Might this be related to this issue?

https://github.com/espressif/esp-idf/pull/586
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

permal
Posts: 384
Joined: Sun May 14, 2017 5:36 pm

Re: lwip macro name clashes

Postby permal » Thu Aug 17, 2017 5:16 am

kolban wrote:Might this be related to this issue?

https://github.com/espressif/esp-idf/pull/586
Yes, and this too: https://github.com/espressif/esp-idf/issues/273

Who is online

Users browsing this forum: No registered users and 104 guests