Created
October 11, 2015 01:27
-
-
Save nicolas17/5e22a2dd52cfa1728fe7 to your computer and use it in GitHub Desktop.
C preprocessor evilness
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
#if EVAL_INPUT % 10 == 0 | |
#define EVAL_D1 0 | |
#elif EVAL_INPUT % 10 == 1 | |
#define EVAL_D1 1 | |
#elif EVAL_INPUT % 10 == 2 | |
#define EVAL_D1 2 | |
#elif EVAL_INPUT % 10 == 3 | |
#define EVAL_D1 3 | |
#elif EVAL_INPUT % 10 == 4 | |
#define EVAL_D1 4 | |
#elif EVAL_INPUT % 10 == 5 | |
#define EVAL_D1 5 | |
#elif EVAL_INPUT % 10 == 6 | |
#define EVAL_D1 6 | |
#elif EVAL_INPUT % 10 == 7 | |
#define EVAL_D1 7 | |
#elif EVAL_INPUT % 10 == 8 | |
#define EVAL_D1 8 | |
#elif EVAL_INPUT % 10 == 9 | |
#define EVAL_D1 9 | |
#endif | |
#if (EVAL_INPUT/10) % 10 == 0 | |
#define EVAL_D2 0 | |
#elif (EVAL_INPUT/10) % 10 == 1 | |
#define EVAL_D2 1 | |
#elif (EVAL_INPUT/10) % 10 == 2 | |
#define EVAL_D2 2 | |
#elif (EVAL_INPUT/10) % 10 == 3 | |
#define EVAL_D2 3 | |
#elif (EVAL_INPUT/10) % 10 == 4 | |
#define EVAL_D2 4 | |
#elif (EVAL_INPUT/10) % 10 == 5 | |
#define EVAL_D2 5 | |
#elif (EVAL_INPUT/10) % 10 == 6 | |
#define EVAL_D2 6 | |
#elif (EVAL_INPUT/10) % 10 == 7 | |
#define EVAL_D2 7 | |
#elif (EVAL_INPUT/10) % 10 == 8 | |
#define EVAL_D2 8 | |
#elif (EVAL_INPUT/10) % 10 == 9 | |
#define EVAL_D2 9 | |
#endif | |
#define CAT_(x,y) x ## y | |
#define CAT(x,y) CAT_(x,y) | |
#define EVAL_RESULT CAT(EVAL_D2, EVAL_D1) |
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
#define EVAL_INPUT 100/4 | |
#include "eval.h" | |
int result = EVAL_RESULT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment