C99 Stdint.H Header and Ms Visual Studio

C99 stdint.h header and MS Visual Studio

Turns out you can download a MS version of this header from:

https://github.com/mattn/gntp-send/blob/master/include/msinttypes/stdint.h

A portable one can be found here:

http://www.azillionmonkeys.com/qed/pstdint.h

Thanks to the Software Ramblings blog.

NB: The Public Domain version of the header, mentioned by Michael Burr in a comment, can be find as an archived copy here. An updated version can be found in the Android source tree for libusb_aah.

Why Microsoft Visual Studio cannot find stdint.h?

EDIT

Note that starting from Visual Studio 2013, C99 library support has been added to Visual Studio.

The answer below is my old answer before Visual Studio 2013 added support:


MSVC has very poor support for the C language, they do not support anything past C90. Herb Sutter has already publicly stated this in his blog.

<cstdint> is supported from MSVC2012.

There is a msinttypes project (exported from the original repo on Google Code) that fills the absence of stdint.h and inttypes.h in Microsoft Visual Studio.

Boost also provides boost/cstdint.hpp if you do not have it.

Where is inttypes.h in Visual Studio 2005?

It's at google. VS doesn't come with <inttypes.h>

stdint.h and C99

Yes.

Incidentally, undefined symbols expand to 0 in preprocessor expressions, so you could just write:

#if __STDC_VERSION__ >= 199901L

On the other hand, an implementation that doesn't claim to conform to C99 (or C11) might still support <stdint.h> as an extension.

Which C99 features are available in the MS Visual Studio compiler?

Fortunately, Microsoft's stance on this issue has changed. MSVC++ version 12.0 (part of Visual Studio 2013) added support for

  • _Bool type.
  • Compound literals.
  • Designated initializers.
  • Mixing declarations with code.
  • __func__ predefined identifier.

You can check the _MSC_VER macro for values greater than or equal to 1800 to see whether these features are supported.

Standard library support has been updated and is mostly complete since MSVC 14.0 (Visual Studio 2015). This release also added the inline keyword.

The restrict keyword, a conformant preprocessor and C11 support arrived in Visual Studio 2019 Release 16.8, but this doesn't include some mandatory C99 features made optional in C11.

Things that earlier versions already supported (I think since at least MSVC 7.1 / Visual Studio 2003):

  • // style comments.
  • long long type.
  • Flexible array members (Microsoft called them "unsized arrays").
  • Variadic macros (at least partially).

Things that are still missing:

  • Variable length arrays (optional in C11, not planned).
  • _Complex type (optional in C11, not planned).
  • C11 multithreading (optional feature, on the roadmap).
  • C11 atomic primitives and types (optional feature, on the roadmap).


Related Topics



Leave a reply



Submit