Re: 32-bit ints on 64-bit linux

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kelly Burkhart <kelly(at)tradebotsystems(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Kelly Burkhart <kelly(at)kkcsm(dot)net>, pgsql-odbc(at)postgresql(dot)org
Subject: Re: 32-bit ints on 64-bit linux
Date: 2005-03-21 19:46:29
Message-ID: 1274.1111434389@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Kelly Burkhart <kelly(at)tradebotsystems(dot)com> writes:
> Can anyone with a better understanding of the libc standard comment on
> the "correctness" of the following lines?

> int8_t i1;
> int16_t i2;

> printf("%d", i1);
> printf("%d", i2);

That's perfectly correct, unless int is narrower than 16 bits on your
platform ;-). Anything narrower than int is implicitly coerced to int
when it's passed to printf. The existence of the h modifier in the
printf format syntax is for scanf, not printf; scanf does have to
know the difference between int and narrower-than-int variables.

regards, tom lane

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Szűcs Gábor 2005-03-22 10:13:36 can't set client_encoding in 7.3.2.9 - crlf bug?
Previous Message Kelly Burkhart 2005-03-21 19:28:59 Re: 32-bit ints on 64-bit linux