Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

38 lines
767 B

  1. /* this header file comes from libowfat, http://www.fefe.de/libowfat/ */
  2. #ifndef ISSET_H
  3. #define ISSET_H
  4. /*
  5. How to check whether a preprocessor symbol is defined or not?
  6. Difficulty: it should work both in the preprocessor:
  7. #if is_set(FOO)
  8. and in C code (and then no code should be generated)
  9. if (is_set(FOO))
  10. We will allow both
  11. #define FOO
  12. and
  13. #define FOO 1
  14. */
  15. /* Original question posed by Linus Torvalds
  16. * https://plus.google.com/102150693225130002912/posts/9gntjh57dXt
  17. * Solution by comex
  18. * https://gist.github.com/2365372
  19. */
  20. #define is_set(macro) is_set_(macro)
  21. #define macrotest_1 ,
  22. #define macrotest_ ,
  23. #define is_set_(value) is_set__(macrotest_##value)
  24. #define is_set__(comma) is_set___(comma 1, 0)
  25. #define is_set___(_, v, ...) v
  26. #endif