currently we have a case where we would like to suppress a certain checker message but the lines of code in question already have a trailing comment. From what I can see, the suppress comment needs to be at the begining of the comment and the normal code comment can come after that.
This way however, the "interesting" comment runs out of screen space.
For us it would be nice if a suppress comment could be at any position within a normal comment.
Command:
cppcheck --inline-suppr --enable=all main.c
working:
int main(void)
{
int x; // cppcheck-suppress unusedVariable normal comment
}
not working:
int main(void)
{
int x; // normal comment cppcheck-suppress unusedVariable
}
Is there a reason for this being forbidden?
Cheers
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hm. I am not against it in principle I just like if there is somewhat strict syntax. do you have some suggestion how a user can clearly indicate that it should be a cppcheck suppression?
if you grep for "TODO cppcheck-suppress" in cppcheck/test/cfg/ then you can see many cases where we want cppcheck to ignore the suppression because we have put the TODO before it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If it is however a TODO to remind code-readers that there are open points here, and those comments are not parsed in any way, I would probably do something like
But, as I said, I have trouble understanding the intent of the code so there might be good reasons to have it as it is.
When it comes to a strict syntax, it's the easier part to come up with some syntax. The problem is the comapatibility with the existing syntax. Parsers tend to get quite messy when allowing too many variations of suppression comments. So I refrain from randomly throwing in suggestion for a comment-embedded syntax here until I understand your case better. :)
Cheers
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
currently we have a case where we would like to suppress a certain checker message but the lines of code in question already have a trailing comment. From what I can see, the suppress comment needs to be at the begining of the comment and the normal code comment can come after that.
This way however, the "interesting" comment runs out of screen space.
For us it would be nice if a suppress comment could be at any position within a normal comment.
Command:
working:
not working:
Is there a reason for this being forbidden?
Cheers
hm. I am not against it in principle I just like if there is somewhat strict syntax. do you have some suggestion how a user can clearly indicate that it should be a cppcheck suppression?
if you grep for "TODO cppcheck-suppress" in cppcheck/test/cfg/ then you can see many cases where we want cppcheck to ignore the suppression because we have put the TODO before it.
Hi,
thanks for your reply.
To be honest, I have problems seeing from a quick glance what the reason for the TODO comments is.
is the same as
right? Or is there a special meening to the TOD comment within the test suite?
If it is not a TODO in its usual meaning, I probably would go with something like
If it is however a TODO to remind code-readers that there are open points here, and those comments are not parsed in any way, I would probably do something like
But, as I said, I have trouble understanding the intent of the code so there might be good reasons to have it as it is.
When it comes to a strict syntax, it's the easier part to come up with some syntax. The problem is the comapatibility with the existing syntax. Parsers tend to get quite messy when allowing too many variations of suppression comments. So I refrain from randomly throwing in suggestion for a comment-embedded syntax here until I understand your case better. :)
Cheers