I would like three lines of code not to be included if compiled after a certain date. The reason being is they provide backwards compatibility. To support a staggered release between client and embedding it is required to be there now.
Once the next software release comes along this support is to be dropped to force customers to upgrade the embedded software. Since this is a few months away there is risk of these lines being forgotten.
So ideally I would like a
#if __DATE__ > MyDate
code here
#endif
or something equivalent. Is there any way of doing this?
*The code is compiled with GCC
This solution is specifically for Windows platform and is something I use in production.
I exploit the environment variable %DATE%, and in a batch file used to launch my IDE, I have VA_CURRENT_DATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2% (which transforms to an ISO8601 date for my specific locale).
Then in my preprocessor definitions for my project I define VA_BUILD_DATE to VA_CURRENT_DATE
Then I have some code like:
long day = VA_BUILD_DATE;
long year = day / 10000;
day -= year * 10000;
long month = day / 100;
day -= month * 100;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With