We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All, let a function prototype is : bit func(); Now if it is used as follows (inadvertently) then what would it do ?? Why not the complier throws an error ?? if (func) { ... ... } else { ... ... } -Rocknmoon()
"if (func)" Funnily enough, I made that very same mistake only the other day! As Mark says, the expression 'func' has the value of the address of func; the if simply tests if the value is zero or not - almost undoubtedly it won't be, so it will always equate to "true" "The compiler could warn..." As I have noted several timed before, "small" cross-compilers like C51 are generally weaker in their diagnostic messages than their "big" native cousins like MSVC, Borland, etc Therefore it is often worthwhile running your code through a "big" compiler for the benefit of the more extensive diagnostics. Or use lint