-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaybeUnused.cpp
38 lines (30 loc) · 957 Bytes
/
MaybeUnused.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* \file maybe_unused.cpp
* \brief [[maybe_unused]]
*
* This attribute is used to suppress compiler/analyzer warnings for unused variables,
* function parameters, static functions, and more.
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//-------------------------------------------------------------------------------------------------
// The warning will be suppressed
[[maybe_unused]] static void SomeUnusedFunc() { /* .... */ }
// The warning will be suppressed
void Foo([[maybe_unused]] int a) { /* .... */ }
void Func()
{
// The warning will be suppressed
[[maybe_unused]] int someUnusedVar = 42;
//....
}
//-------------------------------------------------------------------------------------------------
int main(int, char **)
{
return EXIT_SUCCESS;
}
//-------------------------------------------------------------------------------------------------
#if OUTPUT
// no warnings
#endif