Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 464
Carey Gister Avatar asked Nov 11 '15 21:11

Carey Gister


2 Answers

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_;
  }
like image 115
Andreas ZUERCHER Avatar answered Sep 28 '22 00:09

Andreas ZUERCHER


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.

like image 44
dxiv Avatar answered Sep 27 '22 23:09

dxiv