title: Using snprintf in a cross-platform application
body: <p>I am writing a C program that is expected to be compiled with all major compilers. Currently I am developing on GCC on a linux machine and will compile on MSVC before committing the code. To make the cross-compiling easy, I am compiling with <code>-ansi</code> and <code>-pedantic</code> flags. This worked well until I started using <code>snprintf</code> which is not available in C89 standard. GCC can compile this without the <code>-ansi</code> switch but MSVC will fail always as it doesn't have C99 support. </p>
  
  <p>So I did something like, </p>
  
  <pre><code>#ifdef WIN32 
  #define snprintf sprintf_s
  #endif
  </code></pre>
  
  <p>This works well because <code>snprintf</code> and <code>sprintf_s</code> has same signatures. I am wondering is this the correct approach?</p>