cancel
Showing results for 
Search instead for 
Did you mean: 

Compilation error: macro "bind" requires 3 arguments when using LWIP with TouchGFX (STM32H7)

ksale.1
Senior II

Hello everyone,

I’m working on a project with an STM32H750B-DK board using TouchGFX and LWIP (Ethernet). After configuring LWIP in CubeMX and generating the code, I encountered a compilation error that took me a while to understand. I’d like to share the problem to help anyone who might run into the same issue.

The Error

In file included from ../Application/User/gui/NetworkTask.cpp:13:
../../TouchGFX/gui/include/gui/model/ModelListener.hpp:13:23: error: macro "bind" requires 3 arguments, but only 1 given
   13 |     void bind(Model* m)
      |                       ^
In file included from ../Application/User/gui/NetworkTask.cpp:11:
../../Middlewares/Third_Party/LwIP/src/include/lwip/sockets.h:616: note: macro "bind" defined here
  616 | #define bind(s,name,namelen)                      lwip_bind(s,name,namelen)
      | 

Similar errors appeared for Model.hpp.                                                                                                                            

Root Cause

LWIP’s sockets.h defines a macro bind that replaces any occurrence of bind( with lwip_bind(s,name,namelen). This macro is intended to redirect the BSD bind() function to LWIP’s own implementation. Unfortunately, it also catches any other method named bind – in our case, the bind methods in the TouchGFX MVP classes (Model::bind(ModelListener*) and ModelListener::bind(Model*)). The macro expands them incorrectly, causing the compiler to complain about wrong arguments.                                                   

I hope this helps someone save time debugging this macro clash. Thanks to the community for the help!

Cheers,

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

Hello and thank you for the sharing.

I'm also adding this knowledge base: LwIP integration in a TouchGFX project: recommendations and pitfalls 

I'm accepting that as solution for more visibility to other users..

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
mƎALLEm
ST Employee

Hello and thank you for the sharing.

I'm also adding this knowledge base: LwIP integration in a TouchGFX project: recommendations and pitfalls 

I'm accepting that as solution for more visibility to other users..

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.