Bug 241386

Summary: resolv.h has missing headers, and can't be included alone: error: field has incomplete type 'struct sockaddr_in'
Product: Base System Reporter: Yuri Victorovich <yuri>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Works As Intended    
Severity: Affects Only Me CC: yuripv
Priority: ---    
Version: 12.0-RELEASE   
Hardware: Any   
OS: Any   

Description Yuri Victorovich freebsd_committer freebsd_triage 2019-10-21 06:50:15 UTC
When the header resolv.h is included alone it fails to compile:





$ c++ -c x.cpp
In file included from x.cpp:1:
/usr/include/resolv.h:159:3: error: field has incomplete type 'struct sockaddr_in'
                nsaddr_list[MAXNS];     /*%< address of name server */
                ^
/usr/include/resolv.h:158:9: note: forward declaration of 'sockaddr_in'
        struct sockaddr_in
               ^
/usr/include/resolv.h:173:18: error: field has incomplete type 'struct in_addr'
                struct in_addr  addr;
                                ^
/usr/include/resolv.h:173:10: note: forward declaration of 'in_addr'
                struct in_addr  addr;
                       ^
/usr/include/resolv.h:198:21: error: field has incomplete type 'struct sockaddr_in'
        struct sockaddr_in      sin;
                                ^
/usr/include/resolv.h:158:9: note: forward declaration of 'sockaddr_in'
        struct sockaddr_in
               ^
x.cpp:4:1: error: unterminated /* comment
/*
^
4 errors generated.
Comment 1 Yuri Pankov freebsd_committer freebsd_triage 2019-10-21 06:58:13 UTC
It isn't an error per se unless documentation for some function tells you to include only resolv.h.

Was this found trying to build some real-world software?
Comment 2 Yuri Victorovich freebsd_committer freebsd_triage 2019-10-21 07:00:43 UTC
(In reply to Yuri Pankov from comment #1)

> Was this found trying to build some real-world software?

Yes: https://github.com/vmware/cascade/blob/master/src/common/sockstream.h#L37
Comment 3 Yuri Pankov freebsd_committer freebsd_triage 2019-10-21 07:15:56 UTC
TBH, I don't see a reason for that include to be there at all. Does it compile if include is removed?
Comment 4 Yuri Victorovich freebsd_committer freebsd_triage 2019-10-21 07:26:13 UTC
I asked them to remove the include.

Thanks for your help!