Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixing Doxygen comments with cppcheck-suppress

I have recently learned about:

// cppcheck-suppress noExplicitConstructor
A(int a)
{
    std::cout << a;
}

to make cppcheck ignore some things I don't want to consider errors/warnings. However, I also depend on this style Doxygen comments:

/** This is A's constructor. */
A(int a)
{
    std::cout << a;
}

I tried to do this:

/** This is A's constructor. 
  * cppcheck-suppress noExplicitConstructor
  */
A(int a)
{
    std::cout << a;
}

but cppcheck doesn't pick up that suppression. Is there anyway to embed a cppcheck suppression in a Doxygen-style comment?

like image 231
David Doria Avatar asked May 17 '26 09:05

David Doria


1 Answers

(For the previous versions see the edit history.)

This works for me:

class X {
  public:
  /** a very ugly constructor */
  // cppcheck-suppress uninitvar
  X() { int a; a++; }
};

Now doxygen will correctly see "a very ugly constructor" and cppcheck (installed just for this purpose) with command-line option --inline-suppr suppresses the warning "(error) Uninitialized variable: a".

like image 153
The Vee Avatar answered May 18 '26 22:05

The Vee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!