Carey Gister
Carey Gister

Reputation: 141

Microsoft Integer Literal Extensions -- Where documented?

I came across some integer literals in the standard stdint.h header file on a Windows installation. The literals had suffixes of the form:

i8, ui8, i16, ui16, i32, ui32, i64, ui64.

I have previously encountered suffixes of the form i64 but never any of the others. I was curious as to where these extensions are documented. I spent some time looking through the Microsoft documentation along with other documentation and could not find them.

This is strictly a matter of curiosity. I am clear what the suffixes mean. If any one has a link to the documentation I would appreciate it if you shared the reference.

Thanks in advance!

Upvotes: 7

Views: 2418

Answers (2)

Andreas ZUERCHER
Andreas ZUERCHER

Reputation: 902

If these intrinsic Microsoft-originated literal suffixes were ever to be eliminated due to deprecation or otherwise, then you can write your own exact replacements of each one of them via the user-defined literals of C++11: http://en.cppReference.com/w/cpp/language/user_literal

For example:

constexpr uint16_t
  operator"" ui16 ( uint16_t literal_ )
  noexcept
  {
  return literal_;
  }

Upvotes: 5

dxiv
dxiv

Reputation: 17638

i64 and ui64 were documented in older VC++ versions under "C++ Integer Constants" for example https://msdn.microsoft.com/en-us/library/00a1awxf(v=vs.120).aspx. They are still documented in the latest VC++ 2015 but explicitly advised against for being Microsoft specific and not portable https://msdn.microsoft.com/en-us/library/c70dax92.aspx.

To specify a 64-bit integral type, use the LL, or ll suffix. The i64 suffix is still supported but should be avoided because it is specific to Microsoft and is not portable.

I don't think the others were ever documented at all, and it's probably not a good idea to use them anyway.

Upvotes: 2

Related Questions