Why doesn't Clang like the __DATE__ macro?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
6
down vote

favorite












I use the __DATE__ macro for getting a compile-time year:



const QString build_year = __DATE__ + 7;


The Clang Code Model in QtCreator throws a -Wdate-time warning for using the __DATE__ macro.



warning: expansion of date or time macro is not reproducible



I can disable this warning with -Wno-date-time, but what is wrong with using __DATE__?



What is an "expansion" of the macro, how can it be "reproducible" or "not reproducible", and why is "not reproducible" bad?










share|improve this question



















  • 1




    The builds are going to be different depending on when you build it (because the date is different).
    – CoffeeTableEspresso
    1 hour ago










  • I don't believe clang++ enables -Wdate-time by default (I just tried it on my system and I don't get the warning unless I enable it explicitly). Does QtCreator enable it for you? Or make a Makefile or equivalent? You shouldn't get that warning unless something asks for it.
    – Keith Thompson
    1 hour ago






  • 1




    @KeithThompson default clang scheme in the QTCreator is "Clang-only checks for almost everything" - -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
    – yalov
    1 hour ago










  • @yalov: It's the -Weverything that enables -Wdate-time.
    – Keith Thompson
    1 hour ago














up vote
6
down vote

favorite












I use the __DATE__ macro for getting a compile-time year:



const QString build_year = __DATE__ + 7;


The Clang Code Model in QtCreator throws a -Wdate-time warning for using the __DATE__ macro.



warning: expansion of date or time macro is not reproducible



I can disable this warning with -Wno-date-time, but what is wrong with using __DATE__?



What is an "expansion" of the macro, how can it be "reproducible" or "not reproducible", and why is "not reproducible" bad?










share|improve this question



















  • 1




    The builds are going to be different depending on when you build it (because the date is different).
    – CoffeeTableEspresso
    1 hour ago










  • I don't believe clang++ enables -Wdate-time by default (I just tried it on my system and I don't get the warning unless I enable it explicitly). Does QtCreator enable it for you? Or make a Makefile or equivalent? You shouldn't get that warning unless something asks for it.
    – Keith Thompson
    1 hour ago






  • 1




    @KeithThompson default clang scheme in the QTCreator is "Clang-only checks for almost everything" - -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
    – yalov
    1 hour ago










  • @yalov: It's the -Weverything that enables -Wdate-time.
    – Keith Thompson
    1 hour ago












up vote
6
down vote

favorite









up vote
6
down vote

favorite











I use the __DATE__ macro for getting a compile-time year:



const QString build_year = __DATE__ + 7;


The Clang Code Model in QtCreator throws a -Wdate-time warning for using the __DATE__ macro.



warning: expansion of date or time macro is not reproducible



I can disable this warning with -Wno-date-time, but what is wrong with using __DATE__?



What is an "expansion" of the macro, how can it be "reproducible" or "not reproducible", and why is "not reproducible" bad?










share|improve this question















I use the __DATE__ macro for getting a compile-time year:



const QString build_year = __DATE__ + 7;


The Clang Code Model in QtCreator throws a -Wdate-time warning for using the __DATE__ macro.



warning: expansion of date or time macro is not reproducible



I can disable this warning with -Wno-date-time, but what is wrong with using __DATE__?



What is an "expansion" of the macro, how can it be "reproducible" or "not reproducible", and why is "not reproducible" bad?







c++ clang qt-creator






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 mins ago









Boann

36k1286116




36k1286116










asked 1 hour ago









yalov

12718




12718







  • 1




    The builds are going to be different depending on when you build it (because the date is different).
    – CoffeeTableEspresso
    1 hour ago










  • I don't believe clang++ enables -Wdate-time by default (I just tried it on my system and I don't get the warning unless I enable it explicitly). Does QtCreator enable it for you? Or make a Makefile or equivalent? You shouldn't get that warning unless something asks for it.
    – Keith Thompson
    1 hour ago






  • 1




    @KeithThompson default clang scheme in the QTCreator is "Clang-only checks for almost everything" - -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
    – yalov
    1 hour ago










  • @yalov: It's the -Weverything that enables -Wdate-time.
    – Keith Thompson
    1 hour ago












  • 1




    The builds are going to be different depending on when you build it (because the date is different).
    – CoffeeTableEspresso
    1 hour ago










  • I don't believe clang++ enables -Wdate-time by default (I just tried it on my system and I don't get the warning unless I enable it explicitly). Does QtCreator enable it for you? Or make a Makefile or equivalent? You shouldn't get that warning unless something asks for it.
    – Keith Thompson
    1 hour ago






  • 1




    @KeithThompson default clang scheme in the QTCreator is "Clang-only checks for almost everything" - -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
    – yalov
    1 hour ago










  • @yalov: It's the -Weverything that enables -Wdate-time.
    – Keith Thompson
    1 hour ago







1




1




The builds are going to be different depending on when you build it (because the date is different).
– CoffeeTableEspresso
1 hour ago




The builds are going to be different depending on when you build it (because the date is different).
– CoffeeTableEspresso
1 hour ago












I don't believe clang++ enables -Wdate-time by default (I just tried it on my system and I don't get the warning unless I enable it explicitly). Does QtCreator enable it for you? Or make a Makefile or equivalent? You shouldn't get that warning unless something asks for it.
– Keith Thompson
1 hour ago




I don't believe clang++ enables -Wdate-time by default (I just tried it on my system and I don't get the warning unless I enable it explicitly). Does QtCreator enable it for you? Or make a Makefile or equivalent? You shouldn't get that warning unless something asks for it.
– Keith Thompson
1 hour ago




1




1




@KeithThompson default clang scheme in the QTCreator is "Clang-only checks for almost everything" - -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
– yalov
1 hour ago




@KeithThompson default clang scheme in the QTCreator is "Clang-only checks for almost everything" - -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-unused-macros -Wno-newline-eof -Wno-exit-time-destructors -Wno-global-constructors -Wno-gnu-zero-variadic-macro-arguments -Wno-documentation -Wno-shadow -Wno-switch-enum -Wno-missing-prototypes -Wno-used-but-marked-unused
– yalov
1 hour ago












@yalov: It's the -Weverything that enables -Wdate-time.
– Keith Thompson
1 hour ago




@yalov: It's the -Weverything that enables -Wdate-time.
– Keith Thompson
1 hour ago












2 Answers
2






active

oldest

votes

















up vote
9
down vote



accepted










Having repeated builds reproduce binary-identical outputs is desirable from many points of view. Building identical source code from identical tool chains giving different binaries each time could hide serious problems.



If you don't need to produce identical binaries every time you build identical code just disable that warning. that's why the command-line switch exists.






share|improve this answer
















  • 1




    nice concise answer.
    – CoffeeTableEspresso
    1 hour ago

















up vote
1
down vote













The warning message tells you why. Using the macro does not result in a reproducible build since its value will change over time. A build in 2018 and one in 2019 will not produce the same binary.






share|improve this answer




















    Your Answer





    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52897563%2fwhy-doesnt-clang-like-the-date-macro%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    9
    down vote



    accepted










    Having repeated builds reproduce binary-identical outputs is desirable from many points of view. Building identical source code from identical tool chains giving different binaries each time could hide serious problems.



    If you don't need to produce identical binaries every time you build identical code just disable that warning. that's why the command-line switch exists.






    share|improve this answer
















    • 1




      nice concise answer.
      – CoffeeTableEspresso
      1 hour ago














    up vote
    9
    down vote



    accepted










    Having repeated builds reproduce binary-identical outputs is desirable from many points of view. Building identical source code from identical tool chains giving different binaries each time could hide serious problems.



    If you don't need to produce identical binaries every time you build identical code just disable that warning. that's why the command-line switch exists.






    share|improve this answer
















    • 1




      nice concise answer.
      – CoffeeTableEspresso
      1 hour ago












    up vote
    9
    down vote



    accepted







    up vote
    9
    down vote



    accepted






    Having repeated builds reproduce binary-identical outputs is desirable from many points of view. Building identical source code from identical tool chains giving different binaries each time could hide serious problems.



    If you don't need to produce identical binaries every time you build identical code just disable that warning. that's why the command-line switch exists.






    share|improve this answer












    Having repeated builds reproduce binary-identical outputs is desirable from many points of view. Building identical source code from identical tool chains giving different binaries each time could hide serious problems.



    If you don't need to produce identical binaries every time you build identical code just disable that warning. that's why the command-line switch exists.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 1 hour ago









    Stephen M. Webb

    67927




    67927







    • 1




      nice concise answer.
      – CoffeeTableEspresso
      1 hour ago












    • 1




      nice concise answer.
      – CoffeeTableEspresso
      1 hour ago







    1




    1




    nice concise answer.
    – CoffeeTableEspresso
    1 hour ago




    nice concise answer.
    – CoffeeTableEspresso
    1 hour ago












    up vote
    1
    down vote













    The warning message tells you why. Using the macro does not result in a reproducible build since its value will change over time. A build in 2018 and one in 2019 will not produce the same binary.






    share|improve this answer
























      up vote
      1
      down vote













      The warning message tells you why. Using the macro does not result in a reproducible build since its value will change over time. A build in 2018 and one in 2019 will not produce the same binary.






      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        The warning message tells you why. Using the macro does not result in a reproducible build since its value will change over time. A build in 2018 and one in 2019 will not produce the same binary.






        share|improve this answer












        The warning message tells you why. Using the macro does not result in a reproducible build since its value will change over time. A build in 2018 and one in 2019 will not produce the same binary.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        Jesper Juhl

        14.8k32142




        14.8k32142



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52897563%2fwhy-doesnt-clang-like-the-date-macro%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke