lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>typo .. i meant "unsigned long long", which *is* typically 64-bits on any C99 compliant compiler.
>
>I didn't suggest that anyone "eyeball" anything, and don't feel that my comment deserved such an ad hominem reply.

Hey make such a typo in actual code and all hell breaks loose :)

Sorry I didn't mean to be pompous or self-righteous; I read your earlier comments about Java having less flimsy standards than C which isn't exactly fair, C was initially meant to be "portable assembler" decades before Java was born. Your "most" adds insult to C standards' "at least N bits" injury.

I was also recently bitten in the ass by a bug due to shifting sizeof(long) across compilers, platforms AND OS versions so couldn't let this one pass... I'd rather have learned this from someone else's butt-pain rather than experience it myself.

("nurse! I need another pillow!")

-- p

>
>On May 25, 2013, at 2:03 PM, petah <lua@laufenberg.ch> wrote:
>
>>> On most platforms these days unsigned long is 64 bits (however, note the "most").
>> 
>> That's a very unhelpful comment even if it were true, but it isn't.
>> 
>> First, the sign hardly matters. Second, a C type's size is set in stone by a /compiler/, not a platform or CPU, as is struct alignment. Apple actually changed type sizes from one OSX version to the next. Whether by "most" you mean PCs and/or cellphones, then "most" define long as 32-bit (VisualC @ x64 or Clang/iOS @ x32). The C standards defines ranges, not fixed sizes. In retrospect is seems a bad idea but at the time there were all sorts of funky CPUs... we're lucky they were all binary. A long does currently occupy 8 bytes on *nix64, "mostly", but one can hardly use that probability as a basis for design.
>> 
>> If you want fixed type sizes include "stdint.h" and use uint32_t, say, but watch those truncation warnings.
>> 
>> Making assumptions about C type sizes or suggesting that eyeballing today's landscape is good enough to draw conclusions is year-2000 type shortsightedness and does a real disservice to portable code... or those who'll have to debug it down the road :)
>> 
>> -- p
>> 
>
>
>