![]() |
|
|
| Subject:
g++ problems with strtoll (LLONG_MIN, LLONG_MAX, ULLONG_MAX not defined)
Category: Computers > Programming Asked by: crowdman-ga List Price: $10.00 |
Posted:
23 Apr 2004 09:43 PDT
Expires: 23 Apr 2004 19:40 PDT Question ID: 334912 |
I can't compile in the constants LLONG_MIN, LLONG_MAX, or ULLONG_MAX. These are defined in the system doc for strtoll and strtoull, and appear to be in limits.h, but the compiler won't recognize them (due to layers of #ifdefs). If I turn on -std=c99, it will give me the constants, but it messes everything else up. I've come up with a workaround, so I don't need that. I'm trying to understand if this is a g++ bug, or if I'm doing something wrong. I've got a Redhat Linux Workstation 3 system which I'm running c++ on. I've got all the latest patches from redhat, and I'm running kernel version 2.4.21-9.0.1.EL. g++ version info: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-24) |
|
| There is no answer at this time. |
|
| Subject:
Re: g++ problems with strtoll (LLONG_MIN, LLONG_MAX, ULLONG_MAX not defined)
From: nmiell-ga on 23 Apr 2004 18:06 PDT |
By default, gcc compiles C++ code in 'gnu++98' mode, which is an
implementation of the 1998 ISO C++ standard (as amended) and GNU
extensions. gcc also supports a 'c++98' mode which is strictly the
1998 ISO C++ standard.
Because the long long type (and it's associated minimum and maximum
constants) wasn't introduced to the C language until 1999, the 1998
C++ standard doesn't include them.
Thus, it's perfectly fine (although annoying) for gcc to hide
LLONG_MIN and company from C++ programs.
The next revision of the C++ has largely incorporated the C99 changes,
but that won't help you until the standard is finalized, gcc has
implemented it, and you've upgraded to a version of RHEL that includes
the new gcc.
Until then (or, preferrably forever, from a C++ correctness
standpoint), use the min() and max() methods of the
std::numeric_limits<long long> and std::numeric_limits<unsigned long
long> classes.
For example:
#include <limits>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
numeric_limits<long long> ll;
numeric_limits<unsigned long long> ull;
cout << "long long minimum: " << ll.min() << endl
<< "long long maximum: " << ll.max() << endl
<< "unsigned long long minimum: " << ull.min() << endl
<< "unsigned long long maximum: " << ull.max() << endl;
return 0;
} |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |