Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > long long

Reply
Thread Tools

long long

 
 
Ioannis Vranos
Guest
Posts: n/a
 
      04-16-2004
Hi all,

Is long long supposed to be supported in all C99 implementations?If yes is
it supposed to be 64 bit at least? GCC says that it supports long long, but
i got this:


#include <stdio.h>
#include <limits.h>

int main()
{
printf("Maximum value for long long: %lld\n", LLONG_MAX);
printf("Maximum value for long: %ld\n", LONG_MAX);

}


C:\c>\mingw\bin\gcc -v
Reading specs from /mingw/bin/../lib/gcc-lib/mingw32/3.3.1/specs
Configured with:
.../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --en
able
-languages=c,c++,f77,objc,ada,java --disable-win32-registry --disable-shared
--e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enabl
e-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchr
oniz
ation
Thread model: win32
gcc version 3.3.1 (mingw special 20030804-1)


C:\c>\mingw\bin\gcc -std=c99 -pedantic-errors -O3 -Wall temp.c -o temp
temp.c: In function `main':
temp.c:6: error: `LLONG_MAX' undeclared (first use in this function)
temp.c:6: error: (Each undeclared identifier is reported only once
temp.c:6: error: for each function it appears in.)

C:\c>


Any ideas?






Regards,

Ioannis Vranos



 
Reply With Quote
 
 
 
 
Régis Troadec
Guest
Posts: n/a
 
      04-16-2004

"Ioannis Vranos" <(E-Mail Removed)> a écrit dans le message de
news:c5phu8$n45$(E-Mail Removed)...
> Hi all,


Hi,

>
> Is long long supposed to be supported in all C99 implementations?If yes is
> it supposed to be 64 bit at least? GCC says that it supports long long,

but
> i got this:


Yes.

>
> #include <stdio.h>
> #include <limits.h>
>
> int main()


int main(void)

> {
> printf("Maximum value for long long: %lld\n", LLONG_MAX);
> printf("Maximum value for long: %ld\n", LONG_MAX);
>
> }
>


Your program looks true regarding C99.

<>

> Thread model: win32
> gcc version 3.3.1 (mingw special 20030804-1)
>
>
> C:\c>\mingw\bin\gcc -std=c99 -pedantic-errors -O3 -Wall temp.c -o temp
> temp.c: In function `main':
> temp.c:6: error: `LLONG_MAX' undeclared (first use in this function)
> temp.c:6: error: (Each undeclared identifier is reported only once
> temp.c:6: error: for each function it appears in.)
>
> C:\c>
>
>
> Any ideas?
>


I compiled it properly with gcc 3.3.1 (cygwin) with the same options but the
compilation did'nt succeed with Dev-C++ 4.9.8.0 (uses mingw version of gcc
3.2) and I got the same error. It appears it's a bug of the mingw gcc
portage.
I don't know if it has already been reported. You'll maybe find much more
informations at www.mingw.org.


Regis

>
>
>
>
> Regards,
>
> Ioannis Vranos
>
>
>





 
Reply With Quote
 
 
 
 
Ioannis Vranos
Guest
Posts: n/a
 
      04-16-2004
"Régis Troadec" <(E-Mail Removed)> wrote in message
news:c5plfa$bdj$(E-Mail Removed)...
>
> I compiled it properly with gcc 3.3.1 (cygwin) with the same options but

the
> compilation did'nt succeed with Dev-C++ 4.9.8.0 (uses mingw version of gcc
> 3.2) and I got the same error. It appears it's a bug of the mingw gcc
> portage.



Can you provide me with the results at least, so as to not remain with the
curiosity?






Ioannis Vranos

 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      04-16-2004
Ioannis Vranos wrote:

> Hi all,
>
> Is long long supposed to be supported in all C99 implementations?If yes is
> it supposed to be 64 bit at least? GCC says that it supports long long, but
> i got this:
>
>
> #include <stdio.h>
> #include <limits.h>
>
> int main()
> {
> printf("Maximum value for long long: %lld\n", LLONG_MAX);
> printf("Maximum value for long: %ld\n", LONG_MAX);


> gcc version 3.3.1 (mingw special 20030804-1)


> C:\c>\mingw\bin\gcc -std=c99 -pedantic-errors -O3 -Wall temp.c -o temp
> temp.c: In function `main':
> temp.c:6: error: `LLONG_MAX' undeclared (first use in this function)
> temp.c:6: error: (Each undeclared identifier is reported only once
> temp.c:6: error: for each function it appears in.)


I don't remember if 3.3.1 had a header problem, but 3.3.2 gives me:

Maximum value for long long: 9223372036854775807
Maximum value for long: 2147483647

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      04-16-2004
"Ioannis Vranos" <(E-Mail Removed)> writes:
> Hi all,
>
> Is long long supposed to be supported in all C99 implementations?If yes is
> it supposed to be 64 bit at least?


Yes, and yes.

> GCC says that it supports long long, but i got this:
>
>
> #include <stdio.h>
> #include <limits.h>
>
> int main()
> {
> printf("Maximum value for long long: %lld\n", LLONG_MAX);
> printf("Maximum value for long: %ld\n", LONG_MAX);
>
> }

[...]
> C:\c>\mingw\bin\gcc -std=c99 -pedantic-errors -O3 -Wall temp.c -o temp
> temp.c: In function `main':
> temp.c:6: error: `LLONG_MAX' undeclared (first use in this function)
> temp.c:6: error: (Each undeclared identifier is reported only once
> temp.c:6: error: for each function it appears in.)


A conforming implementation consists of both the compiler and the
library (including header files). Apparently your compiler supports
the long long thype, probably correctly, but your <limits.h> header
doesn't define LLONG_MAX (and I'll bet your library's printf() doesn't
support "%lld").

On at least one system I have access to (Red Hat 9, gcc 3.2.2), this
works correctly.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
 
Reply With Quote
 
Régis Troadec
Guest
Posts: n/a
 
      04-16-2004

"Ioannis Vranos" <(E-Mail Removed)> a écrit dans le message de
news:c5ploo$107k$(E-Mail Removed)...
> "Régis Troadec" <(E-Mail Removed)> wrote in message
> news:c5plfa$bdj$(E-Mail Removed)...
> >
> > I compiled it properly with gcc 3.3.1 (cygwin) with the same options but

> the
> > compilation did'nt succeed with Dev-C++ 4.9.8.0 (uses mingw version of

gcc
> > 3.2) and I got the same error. It appears it's a bug of the mingw gcc
> > portage.

>
>
> Can you provide me with the results at least, so as to not remain with the
> curiosity?


Yes.

<cygwin console>

regis~
$ ls
a.out dev_C dev_CPP tutu.c

regis~
$ cat tutu.c
#include <stdio.h>
#include <limits.h>

int main(void)
{
printf("Max of long long is %lld",LLONG_MAX);
printf("Max of long is %ld", LONG_MAX);
}



regis~
$ gcc --version
gcc (GCC) 3.3.1 (cygming special)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

regis~
$ gcc -std=c99 -pedantic -errors -Wall -O3 -c tutu.c

regis~
$ ls
a.out dev_C dev_CPP tutu.c tutu.o

regis~
$ gcc tutu.o -o tutu

regis~
$ ./tutu
Max of long long is 9223372036854775807Max of long is 2147483647

</cygwin console>


Regis

>
>
>
>
>
>
> Ioannis Vranos
>



 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      04-16-2004
"Keith Thompson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> A conforming implementation consists of both the compiler and the
> library (including header files). Apparently your compiler supports
> the long long thype, probably correctly, but your <limits.h> header
> doesn't define LLONG_MAX (and I'll bet your library's printf() doesn't
> support "%lld").
>
> On at least one system I have access to (Red Hat 9, gcc 3.2.2), this
> works correctly.



Actually limits.h contains:

/*
* limits.h
*
* Defines constants for the sizes of integral types.
*
* NOTE: GCC should supply a version of this header and it should be safe to
* use that version instead of this one (maybe safer).
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <(E-Mail Removed)-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.3 $
* $Author: dannysmith $
* $Date: 2001/11/29 04:26:33 $
*
*/

#ifndef _LIMITS_H_
#define _LIMITS_H_

/* All the headers include this file. */
#include <_mingw.h>

/*
* File system limits
*
* TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
* same as FILENAME_MAX and FOPEN_MAX from stdio.h?
* NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
* required for the NUL. TODO: Test?
*/
#define PATH_MAX (259)

/*
* Characteristics of the char data type.
*
* TODO: Is MB_LEN_MAX correct?
*/
#define CHAR_BIT 8
#define MB_LEN_MAX 2

#define SCHAR_MIN (-12
#define SCHAR_MAX 127

#define UCHAR_MAX 255

/* TODO: Is this safe? I think it might just be testing the preprocessor,
* not the compiler itself... */
#if ('\x80' < 0)
#define CHAR_MIN SCHAR_MIN
#define CHAR_MAX SCHAR_MAX
#else
#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#endif

/*
* Maximum and minimum values for ints.
*/
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX-1)

#define UINT_MAX 0xffffffff

/*
* Maximum and minimum values for shorts.
*/
#define SHRT_MAX 32767
#define SHRT_MIN (-SHRT_MAX-1)

#define USHRT_MAX 0xffff

/*
* Maximum and minimum values for longs and unsigned longs.
*
* TODO: This is not correct for Alphas, which have 64 bit longs.
*/
#define LONG_MAX 2147483647L

#define LONG_MIN (-LONG_MAX-1)

#define ULONG_MAX 0xffffffffUL


/*
* The GNU C compiler also allows 'long long int'
*/
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)

#define LONG_LONG_MAX 9223372036854775807LL
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)

#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)

/* ISO C9x macro names */
#define LLONG_MAX LONG_LONG_MAX
#define LLONG_MIN LONG_LONG_MIN
#define ULLONG_MAX ULONG_LONG_MAX

#endif /* Not Strict ANSI and GNU C compiler */


#endif /* not _LIMITS_H_ */






Ioannis Vranos

 
Reply With Quote
 
Régis Troadec
Guest
Posts: n/a
 
      04-16-2004

"Ioannis Vranos" <(E-Mail Removed)> a écrit dans le message de
news:c5pnpq$14lc$(E-Mail Removed)...
> "Keith Thompson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >


[snipped]

>> /*

> * The GNU C compiler also allows 'long long int'
> */
> #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
>
> #define LONG_LONG_MAX 9223372036854775807LL
> #define LONG_LONG_MIN (-LONG_LONG_MAX-1)
>
> #define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1)
>
> /* ISO C9x macro names */
> #define LLONG_MAX LONG_LONG_MAX
> #define LLONG_MIN LONG_LONG_MIN
> #define ULLONG_MAX ULONG_LONG_MAX
>
> #endif /* Not Strict ANSI and GNU C compiler */
>
>
>


Now you have your answer, it's not a bug in itself
It's just that your header file isn't C99 ready yet.
__STRICT__ANSI__ is defined if you use -ansi, -std=cXX options with gcc.

See the difference :

<piece of my limits.h>

/* limits.h

Copyright 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.

This file is part of Cygwin.

This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */

/*..........*/

/* Minimum and maximum values a `signed long long int' can hold. */
#ifndef __LONG_LONG_MAX__
#define __LONG_LONG_MAX__ 9223372036854775807LL
#endif

#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined
(__STRICT_ANSI__)

#undef LONG_LONG_MIN
#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
#undef LONG_LONG_MAX
#define LONG_LONG_MAX __LONG_LONG_MAX__

/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
#undef ULONG_LONG_MAX
#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
#endif

#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* Minimum and maximum values a `signed long long int' can hold. */
#undef LLONG_MIN
#define LLONG_MIN (-LLONG_MAX-1)
#undef LLONG_MAX
#define LLONG_MAX __LONG_LONG_MAX__

</piece of my limits.h>

Regis

>
> Ioannis Vranos
>



 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      04-17-2004
Ioannis Vranos wrote:
>

.... snip ...
>
> C:\c>\mingw\bin\gcc -std=c99 -pedantic-errors -O3 -Wall temp.c -o temp
> temp.c: In function `main':
> temp.c:6: error: `LLONG_MAX' undeclared (first use in this function)
> temp.c:6: error: (Each undeclared identifier is reported only once
> temp.c:6: error: for each function it appears in.)


Works fine here on gcc 3.2.1. Your gcc is misinstalled.

c:\c\junk>gcc -std=c99 -pedantic -Wall longlong.c

c:\c\junk>.\a
Maximum value for long long: 9223372036854775807
Maximum value for long: 2147483647

c:\c\junk>cat longlong.c
#include <stdio.h>
#include <limits.h>

int main()
{
printf("Maximum value for long long: %lld\n", LLONG_MAX);
printf("Maximum value for long: %ld\n", LONG_MAX);
}

--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush

 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      04-17-2004
"CBFalconer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Ioannis Vranos wrote:
> >

> ... snip ...
> >
> > C:\c>\mingw\bin\gcc -std=c99 -pedantic-errors -O3 -Wall temp.c -o temp
> > temp.c: In function `main':
> > temp.c:6: error: `LLONG_MAX' undeclared (first use in this function)
> > temp.c:6: error: (Each undeclared identifier is reported only once
> > temp.c:6: error: for each function it appears in.)

>
> Works fine here on gcc 3.2.1. Your gcc is misinstalled.



Wrong diagnosis. My gcc is properly installed. It is f***** *p.






Ioannis Vranos

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to ‘(const __gnu_cxx::hash<long long int>) (const long long int&)’ veryhotsausage C++ 1 07-04-2008 05:41 PM
Use of Long and Long Long Bart C C Programming 27 01-15-2008 05:27 AM
long long and long Mathieu Dutour C Programming 4 07-24-2007 11:15 AM
unsigned long long int to long double Daniel Rudy C Programming 5 09-20-2005 02:37 AM
Assigning unsigned long to unsigned long long George Marsaglia C Programming 1 07-08-2003 05:16 PM



Advertisments