devincpp

log_macro

Oct 22nd, 2024 (edited)
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #define DBG_INFO1(fmt, args...) printf("[Info]" fmt, ##args)      // GCC扩展的特性
  3. #define DBG_INFO2(fmt, ...) printf("[Info]" fmt, ##__VA_ARGS__)
  4. #define DBG_INFO3(fmt, ...) printf("[Info]" fmt, __VA_ARGS__)
  5.  
  6. int main()
  7. {
  8.     DBG_INFO1("123");
  9.     DBG_INFO1("123%s", "abc");
  10.     DBG_INFO2("123");
  11.     DBG_INFO2("123%s", "abc");
  12.     // DBG_INFO3("123"); // 报错
  13.     DBG_INFO3("123%s", "abc");
  14.  
  15.     return 0;
  16. }
Add Comment
Please, Sign In to add comment