#if ISR

I have created a very useful macro that will have disastrous results if it is used inside an ISR. A few years from now some unsuspecting soul (who could be me) will probably use it inside an ISR and spend days debugging.

Is there a means of:

#if ISR
tell the clown this is bad
#endif

If not, would this be a useful addition?

Erik

Parents
  • IMHO, not worth it. 'Inside ISR' could also mean 'inside a function called from an ISR and from normal code as well'. How do you detect that?
    I think all you need to do is write a comment next to the macro definition saying 'DON'T EVEN THINK ABOUT USING THIS MACRO IN AN ISR'. After all, isn't part of the philosophy of C 'if you don't know what you are doing, you are in trouble'?

    - mike

Reply
  • IMHO, not worth it. 'Inside ISR' could also mean 'inside a function called from an ISR and from normal code as well'. How do you detect that?
    I think all you need to do is write a comment next to the macro definition saying 'DON'T EVEN THINK ABOUT USING THIS MACRO IN AN ISR'. After all, isn't part of the philosophy of C 'if you don't know what you are doing, you are in trouble'?

    - mike

Children
More questions in this forum