473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

long long

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

Nov 14 '05 #1
13 6898

"Ioannis Vranos" <iv*@guesswh.at.emails.ru> a écrit dans le message de
news:c5**********@ulysses.noc.ntua.gr...
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



Nov 14 '05 #2
"Régis Troadec" <re**@wanadoo.fr> wrote in message
news:c5**********@news-reader2.wanadoo.fr...

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

Nov 14 '05 #3
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

Nov 14 '05 #4
"Ioannis Vranos" <iv*@guesswh.at.emails.ru> 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) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #5

"Ioannis Vranos" <iv*@guesswh.at.emails.ru> a écrit dans le message de
news:c5***********@ulysses.noc.ntua.gr...
"Régis Troadec" <re**@wanadoo.fr> wrote in message
news:c5**********@news-reader2.wanadoo.fr...

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

Nov 14 '05 #6
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...

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 <co***@bird.fu.is.saga-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 (-128)
#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

Nov 14 '05 #7

"Ioannis Vranos" <iv*@guesswh.at.emails.ru> a écrit dans le message de
news:c5***********@ulysses.noc.ntua.gr...
"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...

[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

Nov 14 '05 #8
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

Nov 14 '05 #9
"CBFalconer" <cb********@yahoo.com> wrote in message
news:40***************@yahoo.com...
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

Nov 14 '05 #10
"Régis Troadec" <re**@wanadoo.fr> wrote in message
news:c5**********@news-reader2.wanadoo.fr...

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

Thanks.


Regards,

Ioannis Vranos

Nov 14 '05 #11
"Régis Troadec" <re**@wanadoo.fr> wrote in message
news:c5**********@news-reader2.wanadoo.fr...

Max of long long is 9223372036854775807Max of long is 2147483647

I just downloaded and installed djgpp, which it works:
C:\c>more temp.c
#include <stdio.h>
#include <limits.h>

int main()
{
printf("%lld\n", LLONG_MAX);
}

C:\c>gcc -std=c99 -pedantic-errors temp.c -o temp

C:\c>temp
9223372036854775807

C:\c>


Ioannis Vranos

Nov 14 '05 #12
"Ioannis Vranos" <iv*@guesswh.at.emails.ru> wrote:
"CBFalconer" <cb********@yahoo.com> wrote in message
news:40***************@yahoo.com...
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)


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


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


Well, the compiler itself is fine, AFAICT after some tests. It's
the library that comes with mingw that's broken, as you can see
when you compile and run this program on this implementation:

#include <stdio.h>
int main( void )
{
unsigned long long ull = 0xDEADBEEF12345678ULL;
printf( "%llX\n", ull );
printf( "%llX\n", ull >> 32 );
return 0;
}
Regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc OT guide : http://benpfaff.org/writings/clc/off-topic.html
Nov 14 '05 #13
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);

}
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

I've called this ll.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);
return 0; /* I added this for you. jww */
}
C:\work\c\clc>gcc -Wall -s -O2 ll.c -o ll.exe
C:\work\c\clc>ll
Maximum value for long long: 9223372036854775807
Maximum value for long: 2147483647

C:\work\c\clc>gcc -W -Wall -ansi -pedantic -s -O2 ll.c -o ll.exe
ll.c: In function `main':
ll.c:6: `LLONG_MAX' undeclared (first use in this function)
ll.c:6: (Each undeclared identifier is reported only once
ll.c:6: for each function it appears in.)
ll.c:6: warning: ISO C89 does not support the `ll' printf length
modifier

C:\work\c\clc>gcc -v
Reading specs from c:/djgpp/lib/gcc-lib/djgpp/3.1/specs
Configured with: ../configure i586-pc-msdosdjgpp
--prefix=/dev/env/DJDIR --disab
le-nls
Thread model: single
gcc version 3.1

C:\work\c\clc>gcc -std=c99 -pedantic-errors -Wall -O3 ll.c -o ll.exe
compiles with no errors or warnings.
--
Joe Wright mailto:jo********@comcast.net
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 14 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tim Clacy | last post by:
How is a 64 bit type defined in strict C++? It seems C has support for 'long long' since C99, but not so for C++? Looking through one compiler vendor's standard library headers has clouded the...
7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
5
by: Mark Shelor | last post by:
Problem: find a portable way to determine whether a compiler supports the "long long" type of C99. I thought I had this one solved with the following code: #include <limits.h> #ifdef...
29
by: Richard A. Huebner | last post by:
Is the unsigned long long primitive data type supported in ANSI standard C? I've tried using it a couple of times in standard C, but to no avail. I'm using both MS VIsual C++ 6, as well as the...
9
by: luke | last post by:
Hi everybody, please, can someone explain me this behaviour. I have the following piece of code: long long ll; unsigned int i = 2; ll = -1 * i; printf("%lld\n", ll);
21
by: Charles Sullivan | last post by:
I maintain/enhance some inherited FOSS software in C which has compiler options for quite a few different Unix-like operating systems, many of which I've never even heard of. It would be...
12
by: Ahmad Jalil Qarshi | last post by:
Hi, I have an integer value which is very long like 9987967441778573855. Now I want to convert it into equivalent Hex value. The result must be 8A9C63784361021F I have used...
2
by: PengYu.UT | last post by:
Hi, In python, triple quote (""") can be used to quote a paragraph (multiple lines). I'm wondering if there is any equivalent in C++. For the following code, I could write the long string in a...
10
by: ratcharit | last post by:
Currently using cosine function in math.h Currently I get: 1 = cos(1e^-7) Is there another way for cos to return value of high accuracy say: 0.999999 = cos(1e^-7)
15
by: Oliver Graeser | last post by:
I need a >49 bit integer type. tried sizeof(long long), says 8. 8 byte = 64 bit right? but when I try to assign a value with more than 32 bit, it fails. To illustrate: for (i=0; i<64; i++){...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.