title: c++ preprocessor directive for choosing variable in runtime
body: <p>I'm trying to achieve something like this: I have</p>
  
  <pre><code>struct {
     int var1;
     int var2;
     int var3;
     ......
     int var31;
  }
  </code></pre>
  
  <p>now I have some integer 'r' that I read on runtime, and I want to print value of var##r (that is, if r=6, print var6 from structure), is it possible via preprocessor directives? I understand I can do this by jumping from var1's address sizeof(int) * r times but I want preprocessor to generate whole if-else chain, can I make it somehow do this?</p>
  
  <p>UPDATE: Forgot to mention, cannot modify given struct, thus cannot use array</p>
  
  <p>UPDATE2: I have those limitations (no arrays, nu jumps) because at the end I'm parsing syntax tree generated by clang and I want to have pure if/else statements there</p>