[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Having to define _STANDALONE to get standard <time.h>
On Thu, Apr 18, 2019 at 09:27:51AM +0200, Martin Husemann wrote:
> On Wed, Apr 17, 2019 at 08:27:02PM +0200, tlaronde%polynum.com@localhost wrote:
> > In order to have only standard definitions in <time.h>, I have to
> > define not standard macro _STANDALONE due to inclusion of <sys/time.h>
> > (that does not only contain declarations but definitions of functions?
> > In a header?).
> It only includes <sys/time.h> if _POSIX_C_SOURCE, _XOPEN_SOURCE or
> _NETBSD_SOURCE is defined.
> > Shouldn't it be the reverse, not:
> > #if !defined(_STANDALONE)
> No, the parts protected by that #ifdef should not be available in a standalone
> environment (that is for example bootloaders).
> You did not describe what exact problem you are hitting. Therere are various
> standards in several versions that describe different things that <time.h>
> should export - maybe one of the ifdefs is wrong, but it is not the
> _STANDALONE part directly.
Got it. The problem is that time.h is included in a block:
as long as there are only declarations, this is not a problem. But with
definitions, there are problems.
So my solution is to put the include header at top, as usual (I wanted
to put the declarations nearer the only one stop where they are used).
As far as I understand, the POSIX standard talks only about declarations
of functions. Not definitions.
It seems that _NETBSD_SOURCE is always defined when sys/featuretest.h
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
!defined(_XOPEN_SOURCE) && !defined(_NETBSD_SOURCE)
#define _NETBSD_SOURCE 1
and this header is included almost everywhere.
Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
Main Index |
Thread Index |