Skip to content

Instantly share code, notes, and snippets.

@jnavila
Created April 12, 2012 22:30
Show Gist options
  • Save jnavila/2371469 to your computer and use it in GitHub Desktop.
Save jnavila/2371469 to your computer and use it in GitHub Desktop.
preprocessor macro that returns 1 if macro is set to 1, else 0
#define dummy_macro(...)
#define CONFIG_1 )(1
#define is_set(macro) is_set1(macro)
#define is_set1(macro) is_set2(CONFIG_##macro)
#define is_set2(x) (dummy_macro( x ) +0)
#define FOO 1
is_set(FOO)
is_set(BAR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment