numeric_limits problem

Nathan Myers ncm@nospam.cantrip.org
Wed Sep 9 05:52:00 GMT 1998


Iztok Polanic wrote:

> I want to compile this program with egcs, but I get an error.
> 
> #/usr/local/bin/g++ 3.3.cpp -o test
> 3.3.cpp: In function `int main()':
> 3.3.cpp:9: `numeric_limits' undeclared (first use this function)
> 3.3.cpp:9: (Each undeclared identifier is reported only once
> 3.3.cpp:9: for each function it appears in.)
> 3.3.cpp:9: parse error before `>'
> 3.3.cpp:14: confused by earlier errors, bailing out
> 
> and here's the program
> 
> #include <iostream.h>
> #include <limits.h>
> using namespace std;
> 
> int main()
> {
>         cout << endl
>              << "The range for type short is from "
>              << numeric_limits<short>::min()
>              << " to "
>  ...
>
> This program should be ANSI/ISO compliant and egcs is ANSI/ISO compliant.
> Right? So why doesn't it work??

Two things:

Egcs-1.1 implements lots of ANSI/ISO features, but it's "not there yet".
In particular, the libstdc++ library included is the old, backward-compatibility
version.  The "v3" release (referred to as "all-singing, all-dancing") is
being worked on.  To participate, see http://egcs.cygnus.com/libstdc++-v3.html .

Second, this program is not compliant.  There is no standard header <iostream.h>,
(the standard one is <iostream>) and <limits.h> does not define the numeric_limits 
template; that's in <limits>.

Nathan Myers
ncm@cygnus.com



More information about the Gcc mailing list