Tue 05 Apr 2016 08:55:56 AM UTC, original submission:
If you try to call any macro which uses netifapi_netif_common(), so for example netifapi_netif_set_default(), in some cases the compilation will fail in if the source file is in C++ doesn't include "NULL" definition (from <cstddef>). For example in this trivial case:
--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---
#include "lwip/netifapi.h"
void f(void)
{
struct netif netif;
netifapi_netif_set_default(&netif);
}
--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---
Compilation fails with error message like this:
--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---
arm-none-eabi-g++ -Wall -Wextra -Wshadow -std=gnu++11 -g -ggdb3 -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -MD -MP -IlwIP-integration/include -Iexternal/lwIP/src/include -Ioutput/include -Iexternal/distortos/include -Wno-shadow -c test.cpp -o output/./test.o
In file included from test.cpp:1:0:
test.cpp: In function 'void f()':
external/lwIP/src/include/lwip/netifapi.h:93:87: error: invalid conversion from 'void' to 'netifapi_errt_fn {aka signed char ()(netif*)}' [-fpermissive]
#define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
^
test.cpp:6:2: note: in expansion of macro 'netifapi_netif_set_default'
netifapi_netif_set_default(&netif);
^
external/distortos/Makefile:238: recipe for target 'output/./test.o' failed
external/lwIP/src/include/lwip/netifapi.h:87:7: note: initializing argument 3 of 'err_t netifapi_netif_common(netif*, netifapi_void_fn, netifapi_errt_fn)'
err_t netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
^
make: *** [output/./test.o] Error 1
--- >8 --- >8 --- >8 --- >8 --- >8 --- >8 ---
Including <cstddef> in the source file helps, as well as including <stddef.h> in netifapi.h, so I think that lwIP should include this system header in all headers where NULL is used.
|