<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 7, 2011, at 6:49 PM, Andrew Trick wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Optima; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; "><blockquote type="cite"><blockquote type="cite">And many places in LLVM use<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">(u)int32_t, too.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">If nothing else, uint32_t is more self-documenting.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If a C implementation decides to take on all the portability issues that come from having a 64-bit int, it has to be because 32-bit arithmetic performance is horrible. The uint32_t type makes sense when you need the compact size, or when you depend on modulo 2^32 arithmetic.<br></blockquote></span></span></blockquote><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Optima; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">Then what do we cast to for overflow checking?<br></span></span></blockquote></div><br><div>uint32_t</div><div><br></div><div>This discussion is rather academic. LLVM builds on ILP32, LP64, and LLP64 platforms where an int is 32 bits and plenty fast. I don't think anyone has tried porting it to a platform where that isn't true, but they would likely have to fix a lot of code that uses int/unsigned.</div><div><br></div><div>If we start using uint32_t everywhere, they will now have to check if we really meant "I need exactly 32 bits, regardless of performance", or did we really mean to use uint_fast32_t instead.</div><div><br></div><div>Either way, they get to look at all the code.</div><div><br></div><div>But yeah, if you depend on having exactly 32 bits for an overflow test, use uint32_t.</div><div><br></div><div>Of course a C implementation is not required to have a 32-bit type, so uint32_t may not exist. If you want to pretend to write portable code, you have to stick to uint_least32_t and uint_fast32_t. I have never seen code that does that, and we don't even bother defining these types in DataTypes.h</div><div><br></div><div>/jakob</div><div><br></div></body></html>