We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Does anyone know how to get the pre-processor to spit out a substring? In this case, I want to include only the year from the __DATE__ macro. Something like:
#define YEAR=substr(8,4,__DATE__) const char code ROMSTRING={"COPYRIGHT " YEAR "by such and such company. Compiled on " __DATE__};
where the #define is something the pre-processor can handle.
Thanks
The ISO/IEC 9899:1999(E) document says in paragraph 6.7.8 note 14:
"An array of character type may be initialized by a character string literal, optionally enclosed in braces. Successive characters of the character string literal (including the terminating null character if there is room or if the array is of unknown size)initialize the elements of the array."
eg, see: http://www.keil.com/forum/docs/thread780.asp http://www.keil.com/forum/docs/thread4456.asp http://www.keil.com/forum/docs/thread10747.asp
Sounds like more of a job for the build tool and version control system, not the compiler itself. You could write a script that takes the latest date of a checkin, or one that runs on every checkin, and update a file that contains the copyright year. Perhaps you devote a file just to this purpose, so it can easily be automatically generated. Maybe all the file has is the one line
Copyright.h -- #define LAST_COPYRIGHT_YEAR "2006"
I don't know if (legally) you update the copyright without changing the source. That is, does mere compilation update the copyright date? Or is it just changes to the source?
With current US law, I think updating the copyright date is both unnecessary and useless. Copyright for anything created since 1977 lasts until 70 years after the author's death, not a fixed time since "last touched". Anonymous works and works for hire (most software) are protected for 95 years from initial publication or 120 years from creation (whichever expires first), so again the "last touched" date has no effect on extended the copyright.
www.copyright.gov/.../faq-duration.html
So perhaps it's not worth knocking yourself out to solve the problem.
Compilation should not affect a copyright. Only modified/new code gets a new copyright year.