title: Different results using MS Visual Studio vs GCC
body: <p>I've written a C program and then compiled and run it in MS Visual Studio and then using GCC. The program makes a few simple math calculations. But the outputs/results I get from both are different. The program is based on macros. </p>
  
  <p>Do these programming environments have a different way of handling macros? If so, what is the difference?</p>
  
  <p>EDIT: Sorry, here's the code.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #define mac(a,b) a*a + b*b - 2*a*b
  
  int func(int a, int b) {
      return (a*a + b*b - 2*a*b);
  }
  main() {
      int f, g, i, j, x, y;
      printf("Please enter two integers\n");
      scanf("%d%d", &amp;f, &amp;g);
      printf("f = %d\tg = %d\n", f, g);
      i = f;
      j = g;
      x = func(i, j);
      y = mac(i, j);
      printf("x = %d\ty = %d\n", x, y);
      x = func(++i, ++j);
      i = f;
      j = g;
      y = mac(++i, ++j);
      printf("i = %d\tj = %d\n", i, j);
      printf("x = %d\ty = %d\n", x, y);
  }
  </code></pre>
  
  <p>Here's the output using VS:</p>
  
  <pre><code>f = 7       g = 8 
  x = 1     y = 1 
  i = 10    j = 11 
  x = 1   y = 1
  </code></pre>
  
  <p>And using GCC:</p>
  
  <pre><code>f = 7   g = 8 
  x = 1   y = 1 
  i = 10 j = 11 
  x = 1  y = -39
  </code></pre>
  
  <p>The difference is the last y value. So I'm wondering if the different compilers go through the macro's process differently?</p>