Bug 241386 - resolv.h has missing headers, and can't be included alone: error: field has incomplete type 'struct sockaddr_in'
Summary: resolv.h has missing headers, and can't be included alone: error: field has i...
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-21 06:50 UTC by Yuri Victorovich
Modified: 2019-10-21 07:26 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Victorovich freebsd_committer 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 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 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 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 2019-10-21 07:26:13 UTC
I asked them to remove the include.

Thanks for your help!