| Author |
Message |
Darren L. Weber *nix forums beginner
Joined: 06 Nov 2005
Posts: 5
|
Posted: Thu Jul 20, 2006 8:22 pm Post subject:
newby - error: 'rint' was not declared in this scope
|
|
|
I am trying to compile a utility to create .avi files. See
http://cpbotha.net/im2avi
I'm working on Debian etch (a mix of testing/unstable).
dweber@dnlweber:~/im2avi-0.4$ g++ --version
g++ (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
Copyright (C) 2006 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.
When I try to compile, I am getting a lot of scope errors. I've fixed
a lot of them by just using std:: where it is missing. However, I
don't know a fix for this one:
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:338: error: 'rint' was not declared in this scope
The program source named im2avi_t.cxx includes, among others:
#include <math.h> // where I assume we get rint()
The section of code, among others, that has this error is:
void im2avi_t::update_image_width(bool ignore_aspect)
{
// update class variable
image_width = (int)main_window->im_width_input->value();
// update modulus ui elements
main_window->wm4_output->value(image_width % 4);
main_window->wm8_output->value(image_width % ;
main_window->wm16_output->value(image_width % 16);
// update height if allowed
if (!ignore_aspect && main_window->constrain_aspect_check->value())
{
main_window->im_height_input->value(rint(image_width /
image_aspect_ratio));
update_image_height(true);
}
// we only update the image aspect ratio if the user has told us NOT
to constrain it, but the programmer has NOT
// told us to ignore it, else we get strange interaction when width
changes affect height and vice versa
if (!main_window->constrain_aspect_check->value() && !ignore_aspect
&& image_width > 0 && image_height > 0)
{
update_image_aspect_ratio((float) image_width / (float)
image_height);
}
}
How do I fix this error related to rint()
Thanks in advance, Darren |
|
| Back to top |
|
 |
shadowman615@comcast.net *nix forums beginner
Joined: 23 Jun 2006
Posts: 18
|
Posted: Thu Jul 20, 2006 8:32 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Darren L. Weber wrote:
| Quote: | I am trying to compile a utility to create .avi files. See
http://cpbotha.net/im2avi
I'm working on Debian etch (a mix of testing/unstable).
dweber@dnlweber:~/im2avi-0.4$ g++ --version
g++ (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
Copyright (C) 2006 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.
When I try to compile, I am getting a lot of scope errors. I've fixed
a lot of them by just using std:: where it is missing. However, I
don't know a fix for this one:
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:338: error: 'rint' was not declared in this scope
The program source named im2avi_t.cxx includes, among others:
#include <math.h> // where I assume we get rint()
snip |
| Quote: | How do I fix this error related to rint()
|
did you try :
#include <cmath>
and
std::rint()
?? |
|
| Back to top |
|
 |
shadowman615@comcast.net *nix forums beginner
Joined: 23 Jun 2006
Posts: 18
|
Posted: Thu Jul 20, 2006 8:42 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
shadowman...@comcast.net wrote:
| Quote: | Darren L. Weber wrote:
I am trying to compile a utility to create .avi files. See
http://cpbotha.net/im2avi
I'm working on Debian etch (a mix of testing/unstable).
dweber@dnlweber:~/im2avi-0.4$ g++ --version
g++ (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
Copyright (C) 2006 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.
When I try to compile, I am getting a lot of scope errors. I've fixed
a lot of them by just using std:: where it is missing. However, I
don't know a fix for this one:
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:338: error: 'rint' was not declared in this scope
The program source named im2avi_t.cxx includes, among others:
#include <math.h> // where I assume we get rint()
snip
How do I fix this error related to rint()
did you try :
#include <cmath
and
std::rint()
??
|
Scratch that -- rint() is a C function and not a c++ function -- isn't
in <cmath> or <math.h> at all. |
|
| Back to top |
|
 |
Pete Becker *nix forums Guru
Joined: 22 Feb 2005
Posts: 682
|
Posted: Thu Jul 20, 2006 9:22 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
shadowman615@comcast.net wrote:
| Quote: |
Scratch that -- rint() is a C function and not a c++ function -- isn't
in <cmath> or <math.h> at all.
|
It's in C99's <math.h>, and TR1 adds it to C++'s <math.h> and <cmath>.
So it's worth trying. |
|
| Back to top |
|
 |
Darren L. Weber *nix forums beginner
Joined: 06 Nov 2005
Posts: 5
|
Posted: Thu Jul 20, 2006 9:41 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
shadowman615@comcast.net wrote:
| Quote: | Darren L. Weber wrote:
I am trying to compile a utility to create .avi files. See
http://cpbotha.net/im2avi
I'm working on Debian etch (a mix of testing/unstable).
dweber@dnlweber:~/im2avi-0.4$ g++ --version
g++ (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
Copyright (C) 2006 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.
When I try to compile, I am getting a lot of scope errors. I've fixed
a lot of them by just using std:: where it is missing. However, I
don't know a fix for this one:
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:338: error: 'rint' was not declared in this scope
The program source named im2avi_t.cxx includes, among others:
#include <math.h> // where I assume we get rint()
snip
How do I fix this error related to rint()
did you try :
#include <cmath
and
std::rint()
??
|
Yes, more problems with that:
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:99:
error: '::acos' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:116:
error: '::asin' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:131:
error: '::atan' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:146:
error: '::atan2' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:162:
error: '::ceil' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:177:
error: '::cos' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:192:
error: '::cosh' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:207:
error: '::exp' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:222:
error: '::fabs' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:237:
error: '::floor' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:252:
error: '::fmod' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:262:
error: '::frexp' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:277:
error: '::ldexp' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:292:
error: '::log' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:307:
error: '::log10' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:322:
error: '::modf' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:341:
error: '::pow' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:363:
error: '::sin' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:378:
error: '::sinh' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:393:
error: '::sqrt' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:408:
error: '::tan' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:423:
error: '::tanh' has not been declared
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:339: error: 'rint' is not a member of 'std'
Should I switch to an older compiler? I wonder if these problems are
related to gcc4.0.4 |
|
| Back to top |
|
 |
Darren L. Weber *nix forums beginner
Joined: 06 Nov 2005
Posts: 5
|
Posted: Thu Jul 20, 2006 9:46 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Darren L. Weber wrote:
| Quote: | shadowman615@comcast.net wrote:
Darren L. Weber wrote:
I am trying to compile a utility to create .avi files. See
http://cpbotha.net/im2avi
I'm working on Debian etch (a mix of testing/unstable).
dweber@dnlweber:~/im2avi-0.4$ g++ --version
g++ (GCC) 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)
Copyright (C) 2006 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.
When I try to compile, I am getting a lot of scope errors. I've fixed
a lot of them by just using std:: where it is missing. However, I
don't know a fix for this one:
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:338: error: 'rint' was not declared in this scope
The program source named im2avi_t.cxx includes, among others:
#include <math.h> // where I assume we get rint()
snip
How do I fix this error related to rint()
did you try :
#include <cmath
and
std::rint()
??
Yes, more problems with that:
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:99:
error: '::acos' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:116:
error: '::asin' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:131:
error: '::atan' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:146:
error: '::atan2' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:162:
error: '::ceil' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:177:
error: '::cos' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:192:
error: '::cosh' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:207:
error: '::exp' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:222:
error: '::fabs' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:237:
error: '::floor' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:252:
error: '::fmod' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:262:
error: '::frexp' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:277:
error: '::ldexp' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:292:
error: '::log' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:307:
error: '::log10' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:322:
error: '::modf' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:341:
error: '::pow' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:363:
error: '::sin' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:378:
error: '::sinh' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:393:
error: '::sqrt' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:408:
error: '::tan' has not been declared
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../include/c++/4.0.4/cmath:423:
error: '::tanh' has not been declared
im2avi_t.cxx: In member function 'void
im2avi_t::update_image_width(bool)':
im2avi_t.cxx:339: error: 'rint' is not a member of 'std'
Should I switch to an older compiler? I wonder if these problems are
related to gcc4.0.4
|
I also tried math::rint() and it doesn't work. I don't know where
rint() comes from. How can I trace or find where rint() belongs (I've
already tried google, to no avail)? |
|
| Back to top |
|
 |
shadowman615@comcast.net *nix forums beginner
Joined: 23 Jun 2006
Posts: 18
|
Posted: Fri Jul 21, 2006 12:57 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Darren L. Weber wrote:
<Snipped Errors>
| Quote: |
I also tried math::rint() and it doesn't work. I don't know where
rint() comes from. How can I trace or find where rint() belongs (I've
already tried google, to no avail)?
|
rint() is supposed to round to the nearest integer. Cmath includes a
floor and ceiling function, although this won't do exactly what you're
looking for. Perhaps the simplest thing to do is to define your own
rint() function that takes whatever type
image_width / image_aspect_ratio yeilds and returns that number
rounded to the nearest int.
As long as that's the only place that rint() occurs in your code. You
may need to define versions for other type parameters also, if
necessary. |
|
| Back to top |
|
 |
Frederick Gotham *nix forums Guru
Joined: 09 Jun 2006
Posts: 502
|
Posted: Fri Jul 21, 2006 1:54 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Shadowman posted:
| Quote: | rint() is supposed to round to the nearest integer.
|
Trivial:
template<class IntType,class FloatType>
inline IntType rint(FloatType const val)
{
return (IntType)(val + 0.5);
/* Cast used to suppress truncation warning */
}
--
Frederick Gotham |
|
| Back to top |
|
 |
shadowman615@comcast.net *nix forums beginner
Joined: 23 Jun 2006
Posts: 18
|
Posted: Fri Jul 21, 2006 2:05 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Frederick Gotham wrote:
| Quote: | Shadowman posted:
rint() is supposed to round to the nearest integer.
Trivial:
template<class IntType,class FloatType
inline IntType rint(FloatType const val)
{
return (IntType)(val + 0.5);
/* Cast used to suppress truncation warning */
}
You may want to extend that to work for negative numbers as well, if |
necessary. Also trivial. |
|
| Back to top |
|
 |
Frederick Gotham *nix forums Guru
Joined: 09 Jun 2006
Posts: 502
|
Posted: Fri Jul 21, 2006 2:18 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Shadowman posted:
| Quote: | template<class IntType,class FloatType
inline IntType rint(FloatType const val)
{
return (IntType)(val + 0.5);
/* Cast used to suppress truncation warning */
}
You may want to extend that to work for negative numbers as well, if
necessary. Also trivial.
|
val ? val + 0.5 : val - 0.5
Or perhaps:
val + (val ? 0.5 : -0.5)
I'd hazard a guess that the former would be more efficient...
--
Frederick Gotham |
|
| Back to top |
|
 |
Pete Becker *nix forums Guru
Joined: 22 Feb 2005
Posts: 682
|
Posted: Fri Jul 21, 2006 2:19 pm Post subject:
Re: newby - error: 'rint' was not declared in this scope
|
|
|
Frederick Gotham wrote:
| Quote: | Shadowman posted:
rint() is supposed to round to the nearest integer.
|
It's supposed to round using the current rounding mode, which can be any
of downward, to nearest, toward zero, upward, or an
implementation-defined set of additional modes.
| Quote: |
Trivial:
template<class IntType,class FloatType
inline IntType rint(FloatType const val)
{
return (IntType)(val + 0.5);
/* Cast used to suppress truncation warning */
}
|
With round to nearest, rint(-1.1) should be -1. This function return 0. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|