I am using the sources of project that is in an ongoing development and constantly changes.
In a specific scenario, I must change the sources of the project to adapt it to my own needs.
I want to create a define (or set of defines) that will ensure that if I updated the sources of the external project, and I didn't added my changes again to the new version of the code, I will fail the compile. In other words - I want to protect my self from forgetting writing certain code
How would you recommend?
Using IAR workbench, compiling for TI25XX
You can use the preprocessor directives #ifndef
and #error
:
#ifndef SOMETHING
#error "Error message!"
#endif
If SOMETHING
is not defined, the compilation will halt and "Error message!"
will be displayed.
What SOMETHING
actually is will have to be decided by you. Perhaps it can be a version number1.
#if(CURRENT_VERSION < MINIMUM_VERSION)
#error "Version out of date!"
#endif
1 Suggested by indiv.
I'd suggest you add a Preprocessor Error Directive, #error
, inside a #ifndef
block. For example:
#ifndef YOAVS_SPECIAL_CODE
#error "You forgot the code Yoav."
#endif
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