David Doria David Doria - 14 days ago 9
C++ Question

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?

Answer

(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".

Comments