¿ªÔÆÌåÓý

Re: Bonehead mistake, hard to detect


 

Thanks, guys, lots to learn from that!!!
Gordon


On Sun, May 16, 2021 at 9:56 PM Jack, W8TEE via <jjpurdum=[email protected]> wrote:
I did have them turned on, but I missed the message. The warning was near the top of a project with 22 source code files. I simply didn't see it.

Everyone makes mistakes. At least I admitted it and posted it here in an effort to help others from making the same mistake.

Jack, W8TEE

On Sunday, May 16, 2021, 4:26:40 PM EDT, Ashhar Farhan <farhanbox@...> wrote:


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

--
Jack, W8TEE

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