rspec/rules/S1270/rule.adoc

34 lines
760 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-01-27 13:42:22 +01:00
Explicitly specifying a ``++void++`` parameter list is required in C, but optional in {cpp}. Using ``++void++`` for a parameter-less function decreases its readability. The at-a-glance impression is that the function _does_ take a parameter, and it takes a second look to ascertain that it does not. Therefore the more compact notation is preferred.
2020-06-30 12:47:33 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:47:33 +02:00
----
int fun(void);
int fun(void) {
...
}
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2020-06-30 12:47:33 +02:00
----
int fun();
int fun() {
...
}
----
== Resources
* {cpp} Core Guidelines - https://github.com/isocpp/CppCoreGuidelines/blob/e49158a/CppCoreGuidelines.md#nl25-dont-use-void-as-an-argument-type[NL.25: Don't use `void` as an argument type]