From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28947 invoked by alias); 14 Oct 2002 00:11:45 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 28913 invoked from network); 14 Oct 2002 00:11:43 -0000 Received: from unknown (HELO carriage.chesco.com) (209.195.192.2) by sources.redhat.com with SMTP; 14 Oct 2002 00:11:43 -0000 Received: from carriage.chesco.com (mxfcl8x72.chesco.com [209.195.248.200]) by carriage.chesco.com (8.11.6/8.10.1) with ESMTP id g9E0BgP25888; Sun, 13 Oct 2002 20:11:42 -0400 (EDT) Date: Sun, 13 Oct 2002 17:11:00 -0000 Subject: Re: unsigned long long int with os-x Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v546) Cc: gcc-help@gcc.gnu.org, Nicholas Strauss To: Segher Boessenkool From: Nicholas Strauss In-Reply-To: <3DAA0A1A.CAEECF78@koffie.nl> Message-Id: Content-Transfer-Encoding: 7bit X-SW-Source: 2002-10/txt/msg00159.txt.bz2 Hi Segher, Yes, this works on Macintosh OS-X. u: 9223372036854775808 u--: 9223372036854775807 u++: 9223372036854775809 2u: 0 thanks, Nick On Sunday, October 13, 2002, at 08:04 PM, Segher Boessenkool wrote: > 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 >