__DATE__ macro question

Sysprogs forums Forums VisualGDB __DATE__ macro question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #30641
    roujesky
    Participant

    Hi all:

    I ported an ARM project from Keil to VisualGDB (GCC).  I cannot seem to see a current date from __DATE__ macro.   It returns a date from 3 weeks ago.  Before I ported??   How do I trigger the __DATE__ macro getting updated when I compile?

    thanks!

     

    #30644
    support
    Keymaster

    Hi,

    No problem. First of all, please note that this is outside our regular product support scope, as it is a general C/C++ programming question, rather than a VisualGDB-specific issue.

    However, as we have helped you port the project from Keil to GCC via our consulting service, we will gladly explain this as a part of the porting support.

    The __DATE__ macro is only expanded by the compiler when the corresponding source file is physically compiled. E.g., if none of the project files have changed since the last build, the project will be considered up-to-date, and the old binary with the old __DATE__ value will be preserved. This also works on the file level. E.g. if main.c contains  a printf(__DATE__), or a similar statement, modifying auxiliary.c will build a newer firmware version, but it will still show the old date, because the function checking it was not rebuilt this time.

    If you would like to ensure that the __DATE__ value is always up-to-date, please consider making a dedicated function that checks and returns it in one of the .c files (not headers that are used by multiple sources) and add a custom pre-build step that will reset the timestamp on that .c file (e.g. using the touch command from MinGW or any other similar tool).

    You can also simply do a full rebuild (Build->Rebuild All). This will make sure all files are rebuilt, so the old date will not be cached anywhere.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.