Re: gcc works, but g++ broken


Subject: Re: gcc works, but g++ broken
From: Jim Cole (greyleaf@yggdrasill.net)
Date: Sat Jan 27 2001 - 03:04:59 MST


Hi - I don't believe there is anything wrong with the compiler. One
problem is with your use of literals; they have a default type that is not
64-bit. However, you are assigning 64-bit values to that underlying type.
If you instead do something like

test = -(9223372036854775807LL)-1;
test = 9223372036854775807LL;

you should get a clean compile.

As for INT64_MIN and INT64_MAX, stdint.h includes the following...

/* The ISO C 9X standard specifies that in C++ implementations these
   macros should only be defined if explicitly requested. */
#if !defined __cplusplus || defined __STDC_LIMIT_MACROS

So the macros are only available when __cplusplus is *not* defined or a
specific request is made by defining __STDC_LIMIT_MACROS before including
stdint.h

Everything seems to work as advertised :)

Jim

David Figueiredo's bits of Fri, 26 Jan 2001 translated to:

>Hi All,
>
> I'm hoping that someone on this list can help. Next I'll go the the
>gcc
>bug tracker.
>
> I have a simple example that breaks the compiler. First of all the
>gcc
>will compile the code (below), but g++ will not.
>
> I have tried many permutations. But I cannot use 64bit integers.
>
>----------- code snippet --------------------------
>#include <stdint.h>
>
>/* Cannot use INT64_MIN or INT64_MAX as these
> are undefined when the g++ compiler is run. Even
> thought its clear it should be defined if __cplusplus
> is defined (see stdint.h). Which it seems to be at
> compiler initialization. Go figure?
>*/
>int main()
>{
>
> int64_t test;
>
> test = -(9223372036854775807)-1;
> test = 9223372036854775807;
>
> return 0;
>}
>--------------------------------------------------------------
>
>David Figueiredo
>Software Engineer
>Etec, an Applied Materials Co.
>davidf@etec.com
>
>



This archive was generated by hypermail 2a24 : Sat Jan 27 2001 - 03:05:56 MST