1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://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, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DEMO_LOG_H 17 #define DEMO_LOG_H 18 19 #include <cstdio> 20 21 namespace OHOS { 22 #define DEMO_CHECK_AND_RETURN_RET_LOG(cond, ret, fmt, ...) \ 23 do { \ 24 if (!(cond)) { \ 25 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 26 return ret; \ 27 } \ 28 } while (0) 29 30 #define DEMO_CHECK_AND_RETURN_LOG(cond, fmt, ...) \ 31 do { \ 32 if (!(cond)) { \ 33 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 34 return; \ 35 } \ 36 } while (0) 37 38 #define DEMO_CHECK_AND_BREAK_LOG(cond, fmt, ...) \ 39 if (!(cond)) { \ 40 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 41 break; \ 42 } 43 44 #define DEMO_CHECK_AND_CONTINUE_LOG(cond, fmt, ...) \ 45 if (!(cond)) { \ 46 (void)printf("%s\n", fmt, ##__VA_ARGS__); \ 47 continue; \ 48 } 49 } 50 #endif // DEMO_LOG_H