Skip to content

Instantly share code, notes, and snippets.

@nicolas17
Created October 11, 2015 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas17/5e22a2dd52cfa1728fe7 to your computer and use it in GitHub Desktop.
Save nicolas17/5e22a2dd52cfa1728fe7 to your computer and use it in GitHub Desktop.
C preprocessor evilness
#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)
#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