Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/tracing.h
1 /* 2 * Copyright 2017 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_TRACING_H_ 18 #define WABT_TRACING_H_ 19 20 // Provides a simple tracing class that automatically generates enter/exit 21 // messages using the scope of the instance. 22 // 23 // It also assumes that this file is only included in .cc files. 24 // Immediately before the inclusion of this file, there is a define of 25 // for WABT_TRACING, defining whether tracing should be compiled in for 26 // that source file. 27 28 #ifndef WABT_TRACING 29 #define WABT_TRACING 0 30 #endif 31 32 #include "wabt/common.h" 33 34 namespace wabt { 35 36 #if WABT_TRACING 37 38 // Scoped class that automatically prints enter("->") and exit("<-") 39 // lines, indented by trace level. 40 struct TraceScope { 41 WABT_DISALLOW_COPY_AND_ASSIGN(TraceScope); 42 TraceScope() = delete; 43 TraceScope(const char* method); 44 template <typename... Args> 45 TraceScope(const char* method, const char* format, Args&&... args) 46 : method_(method) { 47 PrintEnter(method); 48 fprintf(stderr, format, std::forward<Args>(args)...); 49 PrintNewline(); 50 } 51 ~TraceScope(); 52 53 private: 54 const char* method_; 55 void PrintEnter(const char* method); 56 void PrintNewline(); 57 }; 58 59 #define WABT_TRACE(method_name) TraceScope _func_(#method_name) 60 61 #define WABT_TRACE_ARGS(method_name, format, ...) \ 62 TraceScope _func_(#method_name, format, __VA_ARGS__) 63 64 #else 65 66 #define WABT_TRACE(method) 67 #define WABT_TRACE_ARGS(method_name, format, ...) 68 69 #endif 70 71 } // end namespace wabt 72 73 #endif // WABT_TRACING_H_