-
Boolean and BOOL
Posted on November 5th, 2011 5 commentsIt took me an hour to fix an Access Violation in one of my source codes tonight. The AV caught my eyes when I thought everything was done correctly, and it is ready for committing changes and hit the bed!
It was a vague AV, giving me just a few NT OS functions in call stack trace, and stopping on any line containing Result (as the return value for a property getter). I reviewed the code several times, everything seemed OK, and I had only changed tens of lines of code, so I was really confused where the hell this AV came from; I mean, I knew which property getter method was causing the error, and the method was not lengthy or complicated, but I had no clue how come it was causing such an AV >-(
Eventually while I was reviewing the changed codes again and again, I noticed something; there was a Windows API call which required a PBOOL parameter, and I had called it twice in the function code. One call was written a while ago, and the other was written tonight. The problem was, for the second call I had defined the parameter as Boolean rather than defining it as BOOL (passing its address using @ operator). That’s a shame!
So here’s a personal note for myself: Do not code at 2 AM, specially when you are kinda sleepy. If you did, make sure your eyes can distinguish between BOOL, and Boolean
5 responses to “Boolean and BOOL”

-
useful…
-
I read your post and I can’t get how passing a Boolean variable address instead of BOOL (LongBool) one would cause a problem as both take 4 bytes long space in the programs virtual space?
-
Greeting,
I’ve sent you message using the “Contact Me” form. please check it and let me know.-Issam
-
Basil Peace April 9th, 2012 at 00:16
There is {$TYPEDADDRESS ON} compiler directive. I use it while developing.
If you used it, you wouldn’t have made such mistake. However, it could be not comfortable sometimes.
Leave a reply
-

Shuhin Ashayeri November 20th, 2011 at 11:46