AutosarC++17_10-A2.8.4¶
C-style comments shall not be used
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
C-style comment delimiters /* ... */are not supposed to be used as they make the source code less readable and introduce errors when nesting a C-style comment in the C-style comment.
Example
// $Id: A2-8-4.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
void Fn(bool b1, bool b2) noexcept {
// Introduces x of type std::int16_t // Compliant
std::int32_t x = 0;
// std::int16_t x = 0; // commented out temporarily, type too small //
// Compliant
if (b1) {
if (b2) {
/*
* Do something special here // Non-compliant
*/
}
}
// /* disable this code temporarily
// if (b1)
// {
// /* TODO: should we do something? */ // Non-compliant - compilation
// error
// }
// */
}
See Also
- MISRA C++ 2008 [6]: 2-7-1 The character sequence /* shall not be used within a C-style comment.
- HIC++ v4.0 [8]: 2.3.1 Do not use the C comment delimiters /* ... */.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
cpp_comment_style |
Use of invalid comment style in C++ unit. |
None |
False |
Options¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
exception¶
exception : str | None = None
invalid¶
invalid : str = '/*'