Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #108181
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: How to fix warning: [-Wdate-time] |
| Date | 2017-04-16 13:45 -0700 |
| Organization | None to speak of |
| Message-ID | <lnd1cct72t.fsf@kst-u.example.com> (permalink) |
| References | (1 earlier) <ocntai$1a6$1@news.xmission.com> <b31df4fa-3791-4093-8d89-5d502e38503d@googlegroups.com> <8e289215-369a-43c5-aa46-9428ad81a224@googlegroups.com> <lnpogdtjmy.fsf@kst-u.example.com> <195fbe3a-b69c-45e4-ac6e-a45a1913a834@googlegroups.com> |
supercat@casperkitty.com writes:
> On Saturday, April 15, 2017 at 5:02:05 PM UTC-5, Keith Thompson wrote:
>> The problem would be that the expansions of __DATE__ and __TIME__ would
>> be whatever was passed on the compiler command line and not, as the
>> standard specifies and a reader will assume, the date and time of
>> translation.
>
> The Standard does not require any particular degree of precision, nor does
> it specify the means via which an implementation would determine the time.
> There is no requirement that platforms which host C compilers need to have
> any kind of real-time clock functionality. If a compiler included a
> command-line option to say "Don't trust the system clock--the time is
> actually 1989-06-05 04:32:10, I don't think the Standard would require that
> the compiler not believe the command line.
Did you check what the standard actually says? For __DATE__,
it says that "If the date of translation is not available, an
implementation-defined valid date shall be supplied.", and similarly
for __TIME__.
> Further, in the event that a project happens to be built in multiple steps
> that occur days apart, I don't think the Standard specifies which moment in
> the build process should be identified by __DATE__ and __TIME__. I would
> think a conforming implementation could defer the evaluation of those
> strings to build time (the compiler would have to supply place-holder text
> and specify everyplace where that text appears within objects' initial
> values, but designing that feature into a compiler and linker would not be
> difficult).
It's "the date [or time] of translation of the preprocessing translation
unit", which implies that it's when translation phase 4 is executed
(that's when macros are expanded). Of course it can differ for
different source files within a project.
[...]
> It is generally accepted that command-line options may direct a conforming
> compiler to behave in non-conforming fashion; if a compiler defines __DATE__
> and __TIME__ before processing -D, and allows the latter definitions to
> override the former, that would yield the indicated behavior without the
> compiler having to provide any specialized feature to override the build
> date and time.
It is generally accepted that command-line options can cause a
conforming implementation to be non-conforming.
"gcc -std=c11 -pedantic" is (let's assume) conforming.
"gcc -std=c11 -pedantic -D__DATE__=42" is not.
[...]
> There are a variety of ways of handling things. If one is using code that
> is maintained by someone else and happens to use __DATE__ and __TIME__,
> being able to override those without having to edit the source file could
> be advantageous, since project management can be easier if imported files
> precisely match versions maintained elsewhere.
Presumably that code uses __DATE__ and __TIME__ for a reason. Sure, you
can do things to break that usage.
You're jumping through multiple hoops looking for ways to violate the
requirements imposed by the standard. Some of those ways might manage
to avoid violating the letter of the standard.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to fix warning: [-Wdate-time] MehdiAmini <atorrses@gmail.com> - 2017-04-13 14:44 +0430
Re: How to fix warning: [-Wdate-time] Barry Schwarz <schwarzb@dqel.com> - 2017-04-13 05:28 -0700
Re: How to fix warning: [-Wdate-time] MehdiAmini <atorrses@gmail.com> - 2017-04-14 12:55 +0430
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-14 08:50 -0700
Re: How to fix warning: [-Wdate-time] Ken Brody <kenbrody@spamcop.net> - 2017-04-14 13:42 -0400
Re: How to fix warning: [-Wdate-time] James Kuyper <jameskuyper@verizon.net> - 2017-04-14 14:26 -0400
Re: How to fix warning: [-Wdate-time] David Brown <david.brown@hesbynett.no> - 2017-04-17 16:26 +0200
Re: How to fix warning: [-Wdate-time] "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-17 10:52 -0400
Re: How to fix warning: [-Wdate-time] David Brown <david.brown@hesbynett.no> - 2017-04-17 20:00 +0200
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-17 08:08 -0700
Re: How to fix warning: [-Wdate-time] David Brown <david.brown@hesbynett.no> - 2017-04-17 20:04 +0200
Re: How to fix warning: [-Wdate-time] Mehdi Amini <atorrses@gmail.com> - 2017-04-15 07:50 +0430
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-15 15:05 -0700
Re: How to fix warning: [-Wdate-time] Ken Brody <kenbrody@spamcop.net> - 2017-04-17 11:42 -0400
Re: How to fix warning: [-Wdate-time] supercat@casperkitty.com - 2017-04-17 08:55 -0700
Re: How to fix warning: [-Wdate-time] "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-17 11:57 -0400
Re: How to fix warning: [-Wdate-time] gazelle@shell.xmission.com (Kenny McCormack) - 2017-04-13 13:09 +0000
Re: How to fix warning: [-Wdate-time] jadill33@gmail.com - 2017-04-13 06:27 -0700
Re: How to fix warning: [-Wdate-time] supercat@casperkitty.com - 2017-04-15 08:56 -0700
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-15 15:01 -0700
Re: How to fix warning: [-Wdate-time] supercat@casperkitty.com - 2017-04-16 11:44 -0700
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-16 13:45 -0700
Re: How to fix warning: [-Wdate-time] Ken Brody <kenbrody@spamcop.net> - 2017-04-17 12:14 -0400
Re: How to fix warning: [-Wdate-time] Ken Brody <kenbrody@spamcop.net> - 2017-04-17 12:06 -0400
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-17 09:25 -0700
Re: How to fix warning: [-Wdate-time] "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-17 12:45 -0400
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-17 12:02 -0700
Re: How to fix warning: [-Wdate-time] "James R. Kuyper" <jameskuyper@verizon.net> - 2017-04-17 15:23 -0400
Re: How to fix warning: [-Wdate-time] Lowell Gilbert <lgusenet@be-well.ilk.org> - 2017-04-18 13:27 -0400
Re: How to fix warning: [-Wdate-time] Ken Brody <kenbrody@spamcop.net> - 2017-04-18 14:23 -0400
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-18 12:10 -0700
Re: How to fix warning: [-Wdate-time] raltbos@xs4all.nl (Richard Bos) - 2017-04-22 21:20 +0000
Re: How to fix warning: [-Wdate-time] James Kuyper <jameskuyper@verizon.net> - 2017-04-22 22:45 -0400
Re: How to fix warning: [-Wdate-time] Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-17 11:30 -0700
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-17 12:30 -0700
Re: How to fix warning: [-Wdate-time] raltbos@xs4all.nl (Richard Bos) - 2017-04-22 21:24 +0000
Re: How to fix warning: [-Wdate-time] Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-27 13:33 -0700
Re: How to fix warning: [-Wdate-time] Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-27 13:26 -0700
Re: How to fix warning: [-Wdate-time] gordonb.5zr1e@burditt.org (Gordon Burditt) - 2017-04-14 13:35 -0500
Re: How to fix warning: [-Wdate-time] supercat@casperkitty.com - 2017-04-14 12:17 -0700
Re: How to fix warning: [-Wdate-time] gordonb.k4gmo@burditt.org (Gordon Burditt) - 2017-04-16 00:04 -0500
Re: How to fix warning: [-Wdate-time] Noob <root@127.0.0.1> - 2017-04-16 11:04 +0200
Re: How to fix warning: [-Wdate-time] supercat@casperkitty.com - 2017-04-16 11:52 -0700
Re: How to fix warning: [-Wdate-time] raltbos@xs4all.nl (Richard Bos) - 2017-04-22 21:28 +0000
Re: How to fix warning: [-Wdate-time] Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-04-18 21:34 -0600
Re: How to fix warning: [-Wdate-time] Keith Thompson <kst-u@mib.org> - 2017-04-17 08:09 -0700
csiph-web