Hi,
I have seen several blog posts on using assertions for embedded systems. For knowing where the assert occurred, there are a few recommended strategies:
a. Pass __FILE__ and __LINE__ as a parameter. However, disadvantage being that __FILE__ will be a huge string with the entire file location.
b. Pass __FILENAME__ (for eg: file1.c) instead of __FILE__ (for eg: C:/Users/R/file1.c) where the location of the file is not used - just the name of the file.
c. Store PC and LR registers.
Questions:
1. __FILENAME__ is not standard. How do we define this during compilation.
2. How to store PC and LR registers? - can you give the C code for this?
3. A lot of functions in my code is part of header files. Does it make a difference when asserts are called in functions which are part of header files?