Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_log_null / public / pw_log_null / log_null.h
1 // Copyright 2020 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15
16 #include "pw_preprocessor/arguments.h"
17 #include "pw_preprocessor/compiler.h"
18 #include "pw_preprocessor/util.h"
19
20 PW_EXTERN_C_START
21
22 // Empty function for compiling out log statements. Since the function is empty
23 // and inline, it should be completely compiled out. This function accomplishes
24 // following:
25 //
26 //   - Uses the arguments to PW_LOG, which avoids "unused variable" warnings.
27 //   - Executes expressions passed to PW_LOG, so that the behavior is consistent
28 //     between this null backend and a backend that actually logs.
29 //   - Checks the printf-style format string arguments to PW_LOG.
30 //
31 // For compatibility with C and the printf compiler attribute, the declaration
32 // and definition must be separate and both marked inline.
33 static inline void pw_log_Ignored(int level,
34                                   unsigned int flags,
35                                   const char* module_name,
36                                   const char* message,
37                                   ...) PW_PRINTF_FORMAT(4, 5);
38
39 static inline void pw_log_Ignored(int level,
40                                   unsigned int flags,
41                                   const char* module_name,
42                                   const char* message,
43                                   ...) {
44   PW_UNUSED(level);
45   PW_UNUSED(flags);
46   PW_UNUSED(module_name);
47   PW_UNUSED(message);
48 }
49
50 PW_EXTERN_C_END
51
52 #define PW_LOG(level, flags, message, ...) \
53   pw_log_Ignored((level),                  \
54                  (flags),                  \
55                  PW_LOG_MODULE_NAME,       \
56                  message PW_COMMA_ARGS(__VA_ARGS__))