buglwIP - A Lightweight TCP/IP stack - Bugs: bug #47625, Error in compilation of C++ source...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #47625: Error in compilation of C++ source using netifapi macros

Submitted by:  Freddie Chopin <freddie_chopin>
Submitted on:  Tue 05 Apr 2016 08:55:56 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

(Jump to the original submission Jump to the original submission)

Tue 05 Apr 2016 07:19:31 PM UTC, comment #7:

Fixed like suggested in comment #5.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 05 Apr 2016 11:49:49 AM UTC, comment #6:

If it works, why not.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 05 Apr 2016 11:35:51 AM UTC, comment #5:

How about something like that (see attached patch)? This is how newlib defines NULL and this solves the issue I had (without including <cstddef> or <stddef.h>).

(file #36839)

Freddie Chopin <freddie_chopin>
Tue 05 Apr 2016 11:09:25 AM UTC, comment #4:

Well, my point was that in lwIP, def.h is meant to provide the definition of 'NULL'. If your compiler setup requires you to use 'NULL' from <cstddef>, you should include this file from cc.h.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 05 Apr 2016 10:55:53 AM UTC, comment #3:

If I include just "lwip/def.h" the error stays the same (obviously)... It's not that I "want" this header, but it seems it is essential when compiling this particular macros in C++ (possibly only in C++11).

Freddie Chopin <freddie_chopin>
Tue 05 Apr 2016 10:46:02 AM UTC, comment #2:

The lwip way would be to include def.h in these files. If you want stddef.h, include it in your cc.h

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 05 Apr 2016 09:05:25 AM UTC, comment #1:

First paragraph should read:

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 if the source file is in C++ and it doesn't include "NULL" definition (from <cstddef>). For example in this trivial case:

Freddie Chopin <freddie_chopin>
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.

Freddie Chopin <freddie_chopin>

 

Attached Files
file #36839:  NULL.patch added by freddie_chopin (407B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by freddie_chopin (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 05 Apr 2016 07:19:31 PM UTCgoldsimonStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Tue 05 Apr 2016 11:49:49 AM UTCgoldsimonStatusNone=>Confirmed
      Assigned toNone=>goldsimon
    Tue 05 Apr 2016 11:35:51 AM UTCfreddie_chopinAttached File-=>Added NULL.patch, #36839

    Back to the top


    Powered by Savane 3.1-cleanup1