maybe some code comments are misidentified as code?
Here is a wrong scanning result, this block is a comment, but one sentence is taken for a code line.
URL:code small
(2)
Function pointers are scanned here as a parameter. How do I fix similar code? I don’t seem to have found a solution from your description of the solution.
URL: Function pointer
About the comments being misidentified as code, it’s true: Our algorithm is currently a little too naive in that respect. We already have a ticket about it. Meanwhile, you should just ignore that issue of the rule.
About the second question:
you mean must used function pointer to a pointer?
this code is bind an event ID to the corresponding function pointer.
like this:
Exceptions
Callback functions are a common occurrence and are usually not passed with a preceding &. There is however little ambiguity so this rule ignores function identifiers when used as a parameter of a function call.
You are right that this code should be accepted as being an exception.
I could see in your code that the reason why we do not detect this situation is because the function pointer is passed by const reference, and we forgot to test that situation. I created a ticket to solve this false positive. You can track its status to know when it will be solved. Thank you for your help!
Meanwhile, you should just ignore these violations, or modify the code as I suggested, it will also work and be more explicit.