¿ªÔÆÌåÓý

Re: Bonehead mistake, hard to detect


 

This what happens if you turn off warnings. Turn them all on. It would have warned that you were implicitly casting a pointer to a different type.
- f

On Mon 17 May, 2021, 12:07 AM Jack, W8TEE via , <jjpurdum=[email protected]> wrote:
All:

I just made a really dumb mistake which proved hard to debug. I was trying to call a function named ReadSelectButtonPress(), which returns an integer value using the call:

?? val = ReadSelectButtonPress;

It was not behaving as expected so I placed some scaffolding print statements in the function, recompiled, ran the code but never saw the debug prints. Clean compile, so errors.

It's one of those flat-forehead mistakes. I left the function's parentheses off the calling statement. I'm not positive, but looking at the number I was seeing for val, I think the code assigns the lvalue for the function into val. If it were really behaving like a pointer to function, it would have executed the function code.

I'd be embarrassed to tell you how long I spent chasing this bug...
--
Jack, W8TEE

Join [email protected] to automatically receive all group messages.