Created
December 10, 2022 11:12
-
-
Save Esonhugh/62a68fc1ec2f93f0494e111ae0c13c7b to your computer and use it in GitHub Desktop.
条件编译Debug模式小工具
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
C header file for debugging print | |
DEBUG_HEADER can be modified | |
and also the if you need debugging in kernel | |
you may need define PRINT as printk or other print funcs. | |
Usage: | |
Compile with gcc and options like `-D DEBUG_MODE` will enable the debug print | |
if no `-D DEBUG_MODE` will not make the debug function work bug defined. | |
@author: Esonhugh | |
*/ | |
// #define DEBUG_MODE | |
#ifndef DEBUG_HEADER_FILE_INCLOUDED | |
#define DEBUG_HEADER_FILE_INCLOUDED | |
#define DEBUG_HEADER "[DEBUG] " | |
#define PRINT printf | |
#ifdef DEBUG_MODE | |
#define DEBUG(str) PRINT(DEBUG_HEADER "%s\n", str) | |
#define DEBUG_VAR_STRING(name, value) PRINT(DEBUG_HEADER "%s: %s\n", name, value) | |
#define DEBUG_VAR_INT(name, value) PRINT(DEBUG_HEADER "%s: %d\n", name, value) | |
#define DEBUG_VAR_LONG(name, value) PRINT(DEBUG_HEADER "%s: %ld\n", name, value) | |
#define DEBUG_VAR_DOUBLE(name, value) PRINT(DEBUG_HEADER "%s: %lf\n", name, value) | |
#else | |
#define DEBUG(str) | |
#define DEBUG_VAR_STRING(name, value) | |
#define DEBUG_VAR_INT(name, value) | |
#define DEBUG_VAR_LONG(name, value) | |
#define DEBUG_VAR_DOUBLE(name, value) | |
#endif | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment