Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How to fix warning: [-Wdate-time] Date: Mon, 17 Apr 2017 08:08:17 -0700 Organization: None to speak of Lines: 50 Message-ID: References: <49quec1a81m1hnbja9vqcj12j2appsmm2n@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="6ede04a56392f1431524e35eef643cab"; logging-data="16572"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9h6YFakLTY85Ob/Grz7Sr" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:rqGN3LY+A1j0YdlH8F6NlYsZ+1I= sha1:Dk5MYMaAIVRqin5HvyL5YB0fhos= Xref: csiph.com comp.lang.c:108203 David Brown writes: > On 14/04/17 20:26, James Kuyper wrote: >> On 04/14/2017 01:42 PM, Ken Brody wrote: >>> On 4/14/2017 11:50 AM, Keith Thompson wrote: >> ... >>>> Why can't you just invoke the compiler without the "-Wdate-time" option, >>>> or with "-Wno-date-time"? >>> >>> Sometimes you only want to disable a warning for a particular piece of code. >>> Why force an entire project to be compiled with "-Wno-date-time" for one >>> macro? >> >> Because the entire project is one for which the motivations for that >> warning don't apply? It is really a rather obscure issue to be warning >> about. >> > > IMHO, it is a very good thing to be warning about. If your program > contains the macros __DATA__ or __TIME__, then your builds are not > reproducible. I cannot think of any other way to make a build > non-deterministic, at least on compilers I have used. > > That means that as long as you avoid these macros, you can use the > generated binary file as a way to check that you have exactly the same > build as on a previous occasion. If you are working on software where > you need to check or qualify your builds in a particular manner, this is > essential. > > So my thoughts about how to "fix" this warning is simply to avoid using > __DATE__ or __TIME__. Sure, the -Wdate-date option is useful if you need reproducible builds. But if you're using __DATE__ and __TIME__, then you apparently *don't* need reproducible builds. The OP, Mehdi Amini, seems to want to use both -Wdate-time and __DATE__/__TIME__, and is looking for (and has found) a way to turn off the effect of -Wdate-time for just one source file. That seems frankly silly. I can imagine using -Wdate-time by default and comparing object files, and then making an exception for the one source file that uses __DATE__ and __TIME__, but the Mehdi's only stated rationale for using -Wdate-time is that "IMHO this warning exists for a reason". -- Keith Thompson (The_Other_Keith) kst-u@mib.org 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"