rspec/rules/S3685/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

52 lines
1.2 KiB
Plaintext

== Why is this an issue?
{cpp} allows you to append a macro value onto the end of a string literal. Prior to {cpp}11, it was possible to do this either with or without a space between the two. But with the introduction of user-defined literals in {cpp}11, the preprocessing of string suffixes changed. To get the same string + macro behavior under {cpp} 11, you must separate the string literal and the macro with a space. Without the space, you'll get a compile error.
For the purpose of preparing for migration to {cpp}11, this rule raises an issue when there's no space between a string literal and a macro.
=== Noncompliant code example
[source,cpp]
----
#define _Hrs " hours"
static const char* OPENING = "7"_Hrs; // Noncompliant
----
=== Compliant solution
[source,cpp]
----
#define _Hrs " hours"
static const char* OPENING = "7" _Hrs; // there's one space after "7"
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Add a space after this string literal.
=== Highlighting
string literal
'''
== Comments And Links
(visible only on this page)
=== on 26 Jul 2016, 16:07:20 Ann Campbell wrote:
I've made a few more changes [~alban.auzeill]
endif::env-github,rspecator-view[]