>sys/mman.h has a check so that
>
>#if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
>
>mincore() will not be defined. Is this intentional? Why would it disappear if 
>you ask for a newer POSIX standard?

mincore() is not defined in a standard; newer standards add the <sys/mman.h>
include and so it is tested for additional definitions which the standard
disallows.

>However, unistd.h has:
>
>#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
>extern int mincore(caddr_t, size_t, char *);
>#endif

So it was moved for some reason.

>This leads to code that includes <sys/types.h>, as per the mincore() manpage, 
>and uses mincore(), but does not compile with g++, but does compile with gcc. 
>Presumably due to different default feature macros. If one happens to include 
><unistd.h> it ends up compiling.

<sys/types.h> is the wrong include; it probably dates from the time
that system headers included few prototypes and all you really needed
were the definitions of the types used in the prototypes.

>I am not sure where the bug lies... is it correct for mman.h not to include 
>mincore() for _POSIX_C_SOURCE > 2 || defined(_XPG4_2)? Other platforms do not 
>seem to exclude them (FreeBSD at least (tested), and I have reason to believe 
>the same is true of netbsd/dragonfly/linux aswell).
>
>Even if it is correct for mincore() to be exluded for certain POSIX levels or 
>similar; is not the unistd definition inconsistent?

You should not ask for POSIX levels unless you want to compile a strictly
conforming programs; if you want to confirm strictly to the interfaces
but also need to use non-portable extensions, then you need to add
-D__EXTENSIONS__ on the compilation command line.

Casper
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to