Messages in this thread | | | Date | Wed, 7 Jul 2004 08:29:16 -0400 | From | Jakub Jelinek <> | Subject | Re: Prohibited attachment type (was 0xdeadbeef) |
| |
On Wed, Jul 07, 2004 at 04:48:36AM -0700, tom st denis wrote: > --- "Richard B. Johnson" <root@chaos.analogic.com> wrote: > > Tom is correct. A literal constant defaults to 'int'. > > I did a bit more messing around with GCC and it seems in > > int x = 4; > if (x == 0xDEADBEEF) { ... } > > It will warn that 0xDEADBEEF is unsigned (which it isn't). Either > there is an obscure clause in the C standard [I personally don't have a > copy of C99 nor do I plan on reading it for this] or GCC cause an > incorrect diagnostic [which isn't in violation of the standards...]
It is certainly not obscure. ISO C99 6.4.4.1#5 says: The type of an integer constant is the first of the corresponding list in which its value can be represented.
For Octal or Hexadecimal Constant and no suffix, the table lists: int unsigned int long int unsigned long int long long int unsigned long long int
Assuming 32-bit int, 0xdeadbeef has unsigned int type.
For Decimal Constant and no suffix, the table lists only: int long int long long int and thus assuming 32-bit int and 64-bit long, 3735928559 has long int type, assuming 32-bit int, 32-bit long and 64-bit long long, 3735928559 has long int type.
Jakub - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |