public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@koffie.nl>
To: Nicholas Strauss <nicks@carriage.chesco.com>
Cc: gcc-help@gcc.gnu.org, Nicholas Strauss <ncs@alum.mit.edu>
Subject: Re: unsigned long long int with os-x
Date: Sun, 13 Oct 2002 17:06:00 -0000	[thread overview]
Message-ID: <3DAA0A1A.CAEECF78@koffie.nl> (raw)
In-Reply-To: <9E647882-DEBB-11D6-BFB0-000393AC01F6@carriage.chesco.com>

Nicholas Strauss wrote:
> 
> Hi,
> 
> I'm trying to use gcc in darwin os-x. I've written the following piece of code:
> 
> int main(int argc, char *argv[])
> {
> unsigned long long int u;
> 
> u = 1<<63;

This is the int 1 shifted by 63 bits to the left; that's "undefined behaviour"
by the C standard (and will probably result in 0).

Write

	u = 1LL << 63;

instead.

> printf("u: %ld uu: %ld\n", u, u-1);
> printf("maxint %ld\n", INT64_MAX);
> }
> 
> What compiler/linker options should I use with gcc?

No special options are needed.  But try out -Wall and -W.

> What format should I use with printf?

"%lld" if I remember correctly.


Have fun,

Segher

  reply	other threads:[~2002-10-14  0:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-13  7:59 Nicholas Strauss
2002-10-13 17:06 ` Segher Boessenkool [this message]
2002-10-13 17:11   ` Nicholas Strauss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3DAA0A1A.CAEECF78@koffie.nl \
    --to=segher@koffie.nl \
    --cc=gcc-help@gcc.gnu.org \
    --cc=ncs@alum.mit.edu \
    --cc=nicks@carriage.chesco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).