diff mbox series

[fix,bootstrap] libcody: Include <netinet/in.h> as needed

Message ID 20201220232904.58E7233E5E@hamza.pair.com
State New
Headers show
Series [fix,bootstrap] libcody: Include <netinet/in.h> as needed | expand

Commit Message

Gerald Pfeifer Dec. 20, 2020, 11:28 p.m. UTC
libcody as originally added to GCC fails to build on *-unknown-freebsd11.4 
and presumably others:

  c++ -std=c++11 -g -include config.h -I ... -MMD -MP -MF netclient.d -c
    -o netclient.o
  .../libcody/netclient.cc:114:3: error: unknown type sockaddr_in6 addr;
                                                      ^~~~~~~~~~~~

sockaddr_in6 is declared in /usr/include/netinet6/in6.h,
which is included by /usr/include/netinet/in.h.

Indeed, per https://man7.org/linux/man-pages/man7/ipv6.7.html

    #include <sys/socket.h>
    #include <netinet/in.h>

should be included, and our own gcc/ada/gsocket.h also has

    #if !(defined (VMS) || defined (__MINGW32__))
    #include <sys/socket.h>
    #include <sys/un.h>
    #include <netinet/in.h>
    :
    #endif


Okay to push?

Gerald


libcody/ChangeLog:

2020-12-21  Gerald Pfeifer  <gerald@pfeifer.com>

	* netclient.cc: Include <netinet/in.h>.
	* netserver.cc: Ditto.
---
 libcody/netclient.cc | 1 +
 libcody/netserver.cc | 1 +
 2 files changed, 2 insertions(+)

Comments

Sebastian Huber Dec. 21, 2020, 11:58 a.m. UTC | #1
On 21/12/2020 00:28, Gerald Pfeifer wrote:

> libcody as originally added to GCC fails to build on *-unknown-freebsd11.4
> and presumably others:
I experienced the same issue with FreeBSD 12 building a cross-compiler.
Nathan Sidwell Dec. 21, 2020, 1:44 p.m. UTC | #2
On 12/20/20 6:28 PM, Gerald Pfeifer wrote:
> libcody as originally added to GCC fails to build on *-unknown-freebsd11.4
> and presumably others:
> 
>    c++ -std=c++11 -g -include config.h -I ... -MMD -MP -MF netclient.d -c
>      -o netclient.o
>    .../libcody/netclient.cc:114:3: error: unknown type sockaddr_in6 addr;
>                                                        ^~~~~~~~~~~~
> 

That should be fixed now
Gerald Pfeifer Dec. 21, 2020, 4:19 p.m. UTC | #3
On Mon, 21 Dec 2020, Nathan Sidwell wrote:
> On 12/20/20 6:28 PM, Gerald Pfeifer wrote:
>> libcody as originally added to GCC fails to build on *-unknown-freebsd11.4
>> and presumably others:
>> 
>>    c++ -std=c++11 -g -include config.h -I ... -MMD -MP -MF netclient.d -c
>>      -o netclient.o
>>    .../libcody/netclient.cc:114:3: error: unknown type sockaddr_in6 addr;
>>                                                        ^~~~~~~~~~~~
> That should be fixed now

libcody/netclient.cc is indeed fixed, after 

  commit 31705b068fa5d6cbd04aa4ac5f5275bad37d2222
  Author: Nathan Sidwell <nathan@acm.org>
  Date:   Mon Dec 21 05:36:32 2020 -0800

    libcody: Add netinet.h
    
    We explicitly need to inlude netinet.h, (despite what happened on my test systems)
    
            libcody/
            * netclient.cc: Add netinet.h.

Note, though, that my patch also fixed libcody/netserver.cc, which still 
failed. Seeing that your commit essentially matches my proposed patch, I 
went ahead and committed the remaining part.

With that libcody now builds (and I'll look into the follow-up patch
you shared).

Thanks,
Gerald
Nathan Sidwell Dec. 21, 2020, 4:44 p.m. UTC | #4
On 12/21/20 11:19 AM, Gerald Pfeifer wrote:

>      We explicitly need to inlude netinet.h, (despite what happened on my test systems)
>      
>              libcody/
>              * netclient.cc: Add netinet.h.
> 
> Note, though, that my patch also fixed libcody/netserver.cc, which still
> failed. Seeing that your commit essentially matches my proposed patch, I
> went ahead and committed the remaining part.
> 
> With that libcody now builds (and I'll look into the follow-up patch
> you shared).

thanks, I didn't realize you had a patch already.

nathan
diff mbox series

Patch

diff --git a/libcody/netclient.cc b/libcody/netclient.cc
index 8cccface71c..c97ed4ca126 100644
--- a/libcody/netclient.cc
+++ b/libcody/netclient.cc
@@ -14,6 +14,7 @@ 
 #include <unistd.h>
 #include <arpa/inet.h>
 #include <sys/un.h>
+#include <netinet/in.h>
 
 #ifndef AI_NUMERICSERV
 #define AI_NUMERICSERV 0
diff --git a/libcody/netserver.cc b/libcody/netserver.cc
index 7e43eb033f4..4e55089161e 100644
--- a/libcody/netserver.cc
+++ b/libcody/netserver.cc
@@ -13,6 +13,7 @@ 
 #include <unistd.h>
 #include <arpa/inet.h>
 #include <sys/un.h>
+#include <netinet/in.h>
 
 #ifndef AI_NUMERICSERV
 #define AI_NUMERICSERV 0