Bug 30317

Summary: Inability to compile programs defining _POSIX_SOURCE
Product: Base System Reporter: arun <arun>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description arun 2001-09-04 17:20:01 UTC
	When a POSIX compliant program uses <sys/socket.h>, it gets 
 	compilation errors. The justification for this I've heard in the
	past is that POSIX doesn't include sockets. However, precluding
	all POSIX compliant programs from using sockets is not a good idea,
	in my opinion.

Fix: Apply the patch below.

$ diff -u /usr/include/sys/types.h- /usr/include/sys/types.h
How-To-Repeat: 	Compile this program:

	#include <sys/types.h>
	#include <sys/socket.h>
	main() {}

	with -D_POSIX_SOURCE
Comment 1 dd freebsd_committer freebsd_triage 2001-09-06 09:35:11 UTC
Responsible Changed
From-To: gnats-admin->freebsd-bugs

misfiled
Comment 2 Joseph Koshy freebsd_committer freebsd_triage 2001-11-22 05:36:07 UTC
If `_POSIX_SOURCE' is defined the system has to make visible the
same namespace as permitted and required by IEEE Std 1003.1-1990,
nothing more, nothing less.

Your patch would make `u_char' .. `uint' visible to programs even
if `_POSIX_SOURCE'  were defined, which would cause portable programs
to break.

If you need to use <sys/socket.h>, then by definition your code
falls outside of the gambit defined by the POSIX standard, so you
should not be defining `_POSIX_SOURCE'.

Incidentally, the `_POSIX_SOURCE' feature test macro is deprecated;
`_POSIX_C_SOURCE' is recommended and can be given a numeric value
corresponding to revision of the POSIX standard desired.

Regards,
Koshy
<jkoshy@freebsd.org>
Comment 3 Joseph Koshy freebsd_committer freebsd_triage 2001-11-22 05:43:27 UTC
State Changed
From-To: open->closed

Seems to be a misunderstanding on how defining 
`_POSIX_SOURCE' is required to change the behaviour of  
the C compilation system.
Comment 4 Bruce Evans 2001-11-25 10:46:39 UTC
On Wed, 21 Nov 2001 jkoshy@FreeBSD.ORG wrote:

>  If you need to use <sys/socket.h>, then by definition your code
>  falls outside of the gambit defined by the POSIX standard, so you
>  should not be defining `_POSIX_SOURCE'.

Correct for the 1990 standard.

>  Incidentally, the `_POSIX_SOURCE' feature test macro is deprecated;
>  `_POSIX_C_SOURCE' is recommended and can be given a numeric value
>  corresponding to revision of the POSIX standard desired.

POSIX.1-200x-draft7 has <sys/socket.h>, and for strict conformance,
_POSIX_C_SOURCE has to be defined as 200xxxL before including any
header.  So the PR mostly applies to POSIX.1-200x.

Bruce