CubeMX generates lwIP-file lwippools.h that does not work when you include lwip.h from a .cpp file
CubeMX (at least since version 6.7, maybe longer) generates the lwippools.h with
#ifdef __cplusplus
extern "C" {
#endifwhich gives empty code if you use the C compiler. But if you include the lwip.h in a .cpp file, it won't compile.
This is because lwippools.h is not used as standard header file but is included inside a enum-declaration/definition in memp.h (via memp_std.h):
typedef enum {
#define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
#include "lwip/priv/memp_std.h"
MEMP_MAX
} memp_t;And now if you let a C++ compiler run over this, you have a extern "C" {...} inside your enum. The long list of errors begins with:
In file included from ../Middlewares/Third_Party/LwIP/src/include/lwip/priv/memp_std.h:142,
from ../Middlewares/Third_Party/LwIP/src/include/lwip/memp.h:54,
from ../LWIP/App/lwip.h:31,
from ../Application/Ethernet/EthernetConnection.cpp:13:
../LWIP/Target/lwippools.h:32:2: error: expected identifier before 'extern'
32 | extern "C" {
| ^~~~~~
../LWIP/Target/lwippools.h:32:2: error: expected '}' before 'extern'For the moment I always remove the #ifdef __cplusplus part from that file after generating in CubeMX, but maybe you want to fix this in the code generator?
