rspec/rules/S822/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

63 lines
1.4 KiB
Plaintext

== Why is this an issue?
It is undefined behaviour if the declarations of an object or function in two different translation units do not have compatible types.
The easiest way of ensuring object or function types are compatible is to make the declarations identical.
=== Noncompliant code example
[source,cpp]
----
// File a.cpp
extern int32_t a;
extern int32_t b [];
extern char_t c;
int32_t f1 ( );
int32_t f2 ( int32_t );
// File b.cpp
extern int64_t a; // Noncompliant, not compatible
extern int32_t b [ 5 ]; // Compliant
int16_t c; // Noncompliant
char_t f1 ( ); // Noncompliant
char_t f2 ( char_t ); // Compliant, not the same function as int32_t f2 ( int32_t )
----
== Resources
* MISRA C:2004, 8.4 - If objects or functions are declared more than once, their types shall be compatible.
* MISRA {cpp}:2008, 3-2-1
* https://wiki.sei.cmu.edu/confluence/x/ftUxBQ[CERT, DCL40-C.] - Do not create incompatible declarations of the same function or object
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Make the multiple declarations of "xxx" compatible with each other.
'''
== Comments And Links
(visible only on this page)
=== is related to: S829
=== is related to: S833
=== is related to: S927
=== is related to: S1047
=== on 20 Oct 2014, 14:30:04 Ann Campbell wrote:
cc [~freddy.mallet]
endif::env-github,rspecator-view[]