<< April 2014 | Home | June 2014 >>

Visual Studio's lack of C99 compliance

I was reintroduced to this old chestnut the other evening.

error C2146: syntax error : missing ';' before identifier 'bar'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Having recently kicked off another project I have again been bitten by Microsoft Visual Studio's lack of C99 compliance. Microsoft stopped at C89 (at least until very recently - Visual Studio 2013 I am lead to believe has C99). The official excuse has longstanding been a lack of demand from Visual Studio customers. I guess this must be true to a point, surprising as it is, but most other compilers seem to have managed. One thing is certain, if you are wanting to use C99 Visual Studio has been a bad choice. Windows ubiquity unfortunately does not really leave you with a choice.

Our friendly error mentioned above is caused by missing types like int64_t and uint64_t, both of which are very convenient for cross platform work. Originally one was left with setting up a couple of handy typesdefs to provide ersatz equivalents for the Windows versions of desired types used in our software. More recently our default fallback has been to provide support for these types by including the msinttypes project in our codebase. It has been around a while now, maintained and has a lenient open source license making it a no brainer to include in projects. Anything that saves time and hassle deserves a mention in my book.

Specifically msinttypes provides an implementation of stdint.h and inttypes.h for Microsoft Visual Studio.