Bug 162952 - [headers] Problems including netinet/tcp_var.h
Summary: [headers] Problems including netinet/tcp_var.h
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 8.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 19:20 UTC by the_mix_room
Modified: 2016-12-22 20:19 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description the_mix_room 2011-11-29 19:20:08 UTC
When attempting to include netinet/tcp_var.h in a c++ file, the compiler throws a number of errors. 

"In file included from INPUT.cpp:1:
/usr/include/netinet/tcp_var.h:51: error: expected ';' before 'tqe_q'
/usr/include/netinet/tcp_var.h:56: error: expected constructor, destructor, or type conversion before '(' token
/usr/include/netinet/tcp_var.h:67: error: expected ';' before 'scblink'
/usr/include/netinet/tcp_var.h:102: error: field 't_segq' has incomplete type
/usr/include/netinet/tcp_var.h:184: error: 'sackhole_head' has not been declared
/usr/include/netinet/tcp_var.h:184: error: expected ';' before 'snd_holes'
/usr/include/netinet/tcp_var.h:318: error: expected ';' before 'tw_2msl'"

I am assuming that I am missing an include, as such I have filed this as a documentation bug.

How-To-Repeat: execute "c++ INPUT" 

INPUT.cpp

1 #include <netinet/tcp_var.h>
2
3 using namespace std;
4
5 int main() {
6             return 0;
7 }
Comment 1 Bruce Evans freebsd_committer freebsd_triage 2011-11-30 05:41:32 UTC
> 1 #include <netinet/tcp_var.h>

Most networking headers have _many_ undocumented prerequisites.
tcp_var.h itself is is not really documented, so you just have to know
what its prerequisites are and shouldn't expect it to work for C++.
You have to be a networking person or use trial and error to know the
prerequisites.  (In 2004, tcp_var.h was not mentioned in any man page.
Now it is mentioned in siftr.4 and hhook.9, and these references are
only usable for human readers of tcp_var.h.  hhook.9 has a synopsis
that can't possibly work due to missing prerequisites for the 1 header
that it satisifies, despite massive pollution internal to this header.)

When I stopped policing prerequisites in 1999, minimal prerequisites
for <netinet/tcp_var.h> were

 	#include <sys/types.h>
 	#include <netinet/in.h>
 	#include <netinet/in_systm.h>
 	#include <netinet/ip_var.h>
 	#include <netinet/tcp.h>

in that order.  These were found by trial and error (many trials and
many errors for each file tested.  The trials included complete tests
of subsets to find a minimum that worked for a range of compilers and
compiler options, and incomplete tests of ordering).  These still work,
at least with gcc and normal compiler options.  They happen to work
for C++ too.

Bruce
Comment 2 Hiren Panchasara freebsd_committer freebsd_triage 2016-12-22 20:19:33 UTC
I am not sure if/where we document prereqs for individual headerfile inclusion.

Please reopen if this is something that should be handled in the tree.