Wednesday, March 19, 2008

C++ TR1: stdint.h still missing from Visual Studio

stdint.h is a disappointing absence from both Visual Studio 2008 and the TR1 feature pack. This header was introduced in the C99 standard library to allow programmers to write more portable code by providing a set of typedefs that specify exact-width integer types, together with the defined minimum and maximum allowable values for each type. This standardized the approach for writing such things as uint32_t and should save countless hours of needless duplication for projects that like to define their own variants such as uint32, UINT32, u32, Xyz32U, etc.

Since the C++ standard was finalized in 1998, it missed this standard header by a year. In the latest update to the C++ standard (namely those extensions covered in TR1), support for this header has been added in the form of the cstdint header.

It is astonishing to find that a header that was standardized 9 years ago has still not made its way into Visual Studio 2008. Not even the recent feature pack beta which included support for most of the TR1 extensions, contained stdint.h! The lack of support for this header was logged as a bug with Microsoft way back in 2005 but is still in the "postponed" bucket.

Thankfully, there are a number of implementations of stdint.h available, the most notable being Paul Hsieh's cross-platform free implementation and also a Microsoft compiler specific implementation. Simply place one of these implementations into the Visual Studio standard include paths and stdint.h support magically appears ... now why can't Microsoft do something like that!

5 comments:

Rob Caldecott said...

Superb! I am using VS2008 and though I was going mad because I couldn't find this header.

Thanks.

Kelmar Firesun said...

It beats me why the Visual Studio team can't be bothered to write a simple header. I was able to roll my own based on the FreeBSD code and simply using the Microsoft specific __intX types. Still, this isn't a painful thing to write, and its good to know that at least a few folks recognized the need for such a header.

Jingshao Chen said...

Totally agree with the blogger!

K1200LT Rider said...

I absolutely agree. If my SW engineering group didn't already use Visual Studio, I'd never choose it to do any more development. In fact, I'm going to try talking my company into switching over to a much more compliant IDE such as Eclipse (or possibly other suggestions I get). I'm tired of the "kinda, sorta, incomplete" MS app compliance with the world outside of Microsoft.

Prashant Mishra said...

I cant use my own stdint.h
Other libraries are dependent on the libraries i am building. they have excluded the stdint.h local file from their libraries. I am using gnumake for building. in makefile i have included c99 libraries. but it still not working, there are some issues with that. So, I was thinking about adding c99 library support to my VS2008 project. Can I do that, and if I can, HOW?