2012/8/3 Chris Peterson <[email protected]> > On 8/3/12 1:57 PM, Blake Kaplan wrote: > >> This is the second time this week that the prospect of replacing PRUintX >> in >> favor of stdint types has come up on this newsgroup. The JS engine already >> went through the pain of getting the include/type definition stuff right >> across the various platforms, so I'm wondering if there's a reason to not >> move >> to using them. >> > > I think the original question brought up two issues: > > 1. Using PRTypes versus non-PRTypes (C or stdint) types > 2. Using explicity-sized types: uint32_t versus unsigned int > > re #2: > > Google's C++ Style Guide recommends [1] using (plain) signed `int` for > most numbers (even sizes and loop counters that are always nonnegative). > Explicitly-sized stdint types are only used when integer size is important. > Unsigned ints are only used for bit-manipulation. >
What it really says is: "Of the built-in C++ integer types, the only one used is int. If a program needs a variable of a different size, use a precise-width integer type from <stdint.h>, such as int16_t. " What this means is that it discourages the use of short and long. But it doesn't discourage from using explicitly-sized types such as int16_t. The point is that - if you don't care, use int, - if you do care, use explicitly-sized types, - that doesn't leave any room for wanting to use short or long. I entirely agree with the Google guide on this! Too bad they don't seem to follow it in WebKit (which has plenty of short/long). Benoit > > In contrast, Adobe's Flash Player team prefered explicitly-sized stdint > types everywhere. The thought was that this would make security audits > easier when looking for integer overflow or bitshifting bugs. Flash has > been ported to many different computer architectures and cross-platform > consistency is a high priority. > > > chris p. > > > [1] https://google-styleguide.**googlecode.com/svn/trunk/** > cppguide.xml#Integer_Types<https://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Integer_Types> > > > > ______________________________**_________________ > dev-platform mailing list > [email protected] > https://lists.mozilla.org/**listinfo/dev-platform<https://lists.mozilla.org/listinfo/dev-platform> > _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

