Advertisement
Guest User

Untitled

a guest
Apr 12th, 2012
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define is_set(macro) is_set_(macro)
  4. #define macrotest_1 ,
  5. #define is_set_(value) is_set__(macrotest_##value)
  6. #define is_set__(comma) is_set___(comma 1, 0)
  7. #define is_set___(_, v, ...) v
  8.  
  9. #define CONFIG_FOO 1
  10. #define CONFIG_NOO 0
  11.  
  12. int main()
  13. {
  14.     printf("It's %d!\n", is_set(FOO));
  15.     if(is_set(CONFIG_FOO))
  16.     {
  17.         puts("And it's true, yo!\n");
  18.     }
  19.     if(is_set(CONFIG_NOO))
  20.     {
  21.         puts("Noooo!");
  22.     }
  23.     if(is_set(CONFIG_NOTEXIST))
  24.     {
  25.         puts("NOT EXIST");
  26.     }
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement