www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/07/02/21:31:28

Date: Thu, 2 Jul 1998 21:31:24 -0400 (EDT)
Message-Id: <199807030131.VAA21392@delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: nate AT cartsys DOT com
CC: djgpp-workers AT delorie DOT com
In-reply-to: <359B2300.2387E7DA@cartsys.com> (message from Nate Eldredge on
Wed, 01 Jul 1998 23:04:48 -0700)
Subject: Re: Cross-compiling djlsr

> 1.  If none of the macros __STRICT_ANSI__, _POSIX_SOURCE, etc. were
> defined by the source, the system headers take it upon themselves to
> define _POSIX_SOURCE.

This is a bug, and may be a violation of POSIX.1.

> This leads to problems when compiling things like djasm, since
> DJGPP's coff.h only defines the important stuff ifndef
> _POSIX_SOURCE.

To work around this bug, djasm.y should #undef _POSIX_SOURCE and
anything else causing problems before including djgpp-specific
headers.

> It seems that Linux's headers think of these macros inclusively.
> For instance, _GNU_SOURCE allows all GNU extensions but also defines
> _POSIX_SOURCE, which they consider a subset.  DJGPP, OTOH, uses them
> *ex*clusively-- _POSIX_SOURCE turns off everything not allowed by
> POSIX.  I wonder who is right?

From the POSIX spec (typos are mine):

"Feature test macros shall be defined in the compilation of an
 application before an #include of any header where a symbol should be
 visible to some, but not all, applications"

Later, it defines the following feature test macro:

_POSIX_SOURCE	When an application includes a header described by
		POSIX.1, and when this feature test macro is defined
		according to the preceding rules:

		(1) All symbols required by POSIX.1 to appear when
		    the header is included shall be made visible.

		(2) Symbols that are explicitly permissted, but not
		    required, by POSIX.1 to appear in that header
		    (including those in reserved namespaces) may by
		    made visible.

		(3) Additional symbols not required or explicitly per-
		    mitted by POSIX.1 to be in that header shall not
		    be made visible

Later, it reads (among other things):

"If _POSIX_SOURCE is defined before any header is included, no symbols
 other than those from the C Standard {2} and those made visible by
 feature test macros defined for the program (including _POSIX_SOURCE)
 will be visible."

My interpretation of this is that _POSIX_SOURCE must only be defined
by the application, and may never be defined by any header, since its
definition controls the meaning of future header files, rather than
indicate the usefulness of past header files.

Note that AIX and IRIX headers work the same as DJGPP; defining
_POSIX_SOURCE limits headers to posix-defined stuff.

> 2.  When cross-compiling, everything uses misc.exe.  That's fine, but it
> caused the following gotcha.  After failing in my attempt to
> cross-compile, I loaded dosemu, and thought I'd try compiling that way. 
> So I did a `make clean' to get rid of all the Linux stuff.  Oops!  It
> uses `misc rm', and misc.exe is a Linux ELF binary!  dosemu crashes, and
> I spend several minutes thinking it's a bug in it.

Run "make clean" on the same platform you did the build on.  Not much
we can do here, since there's no portable system-inherent way to
delete files.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019