Discussion:
Error when including 'limits' standard c++ library
(too old to reply)
dailos
2009-06-23 21:01:38 UTC
Permalink
Hi all,

I've got a compiler error when I include math or limits c++
standard libraries as follows:

#include <limits>
int main()
{
return 0;
}

I'm running gcc compiler on a unix system in this way:
g++ example.cpp

and the following error comes up:
limits: "No such file or directory"

The files which contain these statements belong to boost libraries.
So i guess there is something wrong with the
system or compiler.
I realised writing #include <limits.h> solves the problem.
But is not also the first expression grammatically correct in
standard c++?
Am I using a non-standard compiler?
As the source code comes from third-party libraries, how could I
bypass this issue avoiding to modify the
current file?

Many thanks in advance.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Francis Glassborow
2009-06-24 01:37:25 UTC
Permalink
Post by dailos
Hi all,
I've got a compiler error when I include math or limits c++
#include <limits>
int main()
{
return 0;
}
g++ example.cpp
limits: "No such file or directory"
The files which contain these statements belong to boost libraries.
So i guess there is something wrong with the
system or compiler.
I realised writing #include <limits.h> solves the problem.
But is not also the first expression grammatically correct in
standard c++?
No, the version without suffix is climits. In general any standard C
header file name converts to a C++ one by dropping the .h and prepending
a c. So, for example:

stdio.h -> cstdio

There is one place where this is essential because both <string> and
<cstring> are C++ header files but are entirely different.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Ron
2009-06-24 01:40:45 UTC
Permalink
"limits.h" is grammatically correct, but it refers to a
different file than <limits>. "limits.h" is the C language
limits file (also available in C++ as <climits>). It won't
have the numeric_limits template you are looking for.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
dailos
2009-06-24 09:55:16 UTC
Permalink
Post by Ron
"limits.h" is grammatically correct, but it refers to a
different file than <limits>. "limits.h" is the C language
limits file (also available in C++ as <climits>). It won't
have the numeric_limits template you are looking for.
--
[ Seehttp://www.gotw.ca/resources/clcm.htmfor info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
{ Do we really need the quoted clc++m banner? Please remove it. -mod }

OK, they refer to different libraries.
Why does my compiler complain about the first expression then?

I found the statement in some boost libraries. I need to be able to
compile this expression in order to use boost with my project.
Am I using an old compiler?
Thanks!
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Ron
2009-06-24 19:22:05 UTC
Permalink
Post by dailos
I found the statement in some boost libraries. I need to be able to
compile this expression in order to use boost with my project.
Am I using an old compiler?
Thanks!
It's noncompliant with any of the C++ standard versions. It's evidentally
not uncommon because if you look in the boost headers you'll see that they
have code that handles implementations that are missing <limits> by replacing
it with their own. If you're using boost with this compiler, configuring
boost right will cover up this sin.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Ulrich Eckhardt
2009-06-24 09:52:19 UTC
Permalink
Post by dailos
I've got a compiler error when I include math or limits c++
#include <limits>
[...]
Post by dailos
limits: "No such file or directory"
That would be in violation of the C++ standard. My guess: you are using an
ancient compiler version.

Uli
--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Loading...