看看cppcheck
来源(文件preprocessor.cpp http://trac.cppcheck.net/browser/lib/preprocessor.cpp功能RemoveComments()
),看来你做不到。
识别评论的代码是:
if (str.compare(i, 2, "//") == 0) { /* ... */ }
and
else if (str.compare(i, 2, "/*") == 0) { /* ... */ }
当找到评论时,管理警告抑制的代码是:
if (_settings && _settings->_inlineSuppressions) {
std::istringstream iss(comment);
std::string word;
iss >> word;
if (word == "cppcheck-suppress") {
iss >> word;
if (iss)
suppressionIDs.push_back(word);
}
}
So cppcheck
将跳过空格并立即检查第一个标记//
or /*
.
不幸的是,Doxygen 的特殊评论块以/**
, ///
, /*!
or //!
第三个字符阻止“正确匹配”。
改变:
if (word == "cppcheck-suppress") { /* ... */ }
into:
if (contains(word, "cppcheck-suppress")) { /* ... */ }
// or if (ends_with(word, "cppcheck-suppress"))
应该允许你想要的:
/**
* API function description
*
* @param p1 function pointer to the ...
* @return 0 if successful, -1 otherwise.
*/
/** cppcheck-suppress unusedFunction */
or
/// API function description
///
/// @param p1 function pointer to the ...
/// @return 0 if successful, -1 otherwise.
///
/// cppcheck-suppress unusedFunction
您或许可以在以下位置开票http://trac.cppcheck.net/ http://trac.cppcheck.net/