Skip to content

Instantly share code, notes, and snippets.

@gcmurphy
Created November 5, 2012 07:03
Show Gist options
  • Save gcmurphy/4015727 to your computer and use it in GitHub Desktop.
Save gcmurphy/4015727 to your computer and use it in GitHub Desktop.
Macro example of unfolding a for loop for certain values.
// for loop unravelled using macro expansion
// in case i ever want to enter the obsfucated c
// contest '-)
#define X0(h, s, n) (T[(h) ^ (int)(s+n)[0]])
#define X1(h, s, n) X0((X0(h, s, n)), s, n-1 )
#define X2(h, s, n) X1((X1(h, s, n)), s, n-2 )
#define X3(h, s, n) X2((X2(h, s, n)), s, n-4 )
#define X4(h, s, n) X3((X3(h, s, n)), s, n-8 )
#define X5(h, s, n) X4((X4(h, s, n)), s, n-16 )
#define X6(h, s, n) X5((X5(h, s, n)), s, n-32 )
#define X7(h, s, n) X6((X6(h, s, n)), s, n-64 )
#define X8(h, s, n) X7((X7(h, s, n)), s, n-128 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment