473,398 Members | 2,404 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,398 software developers and data experts.

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 % 8);
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

Jul 20 '06 #1
14 8977

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()

??

Jul 20 '06 #2

shadowman...@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()

??
Scratch that -- rint() is a C function and not a c++ function -- isn't
in <cmathor <math.hat all.

Jul 20 '06 #3
sh**********@comcast.net wrote:
>
Scratch that -- rint() is a C function and not a c++ function -- isn't
in <cmathor <math.hat all.
It's in C99's <math.h>, and TR1 adds it to C++'s <math.hand <cmath>.
So it's worth trying.
Jul 20 '06 #4

sh**********@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

Jul 20 '06 #5

Darren L. Weber wrote:
sh**********@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)?

Jul 20 '06 #6

Darren L. Weber wrote:
<Snipped Errors>
>
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.

Jul 21 '06 #7
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 */
}
--

Frederick Gotham
Jul 21 '06 #8

Frederick Gotham wrote:
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.

Jul 21 '06 #9
Shadowman posted:
>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
Jul 21 '06 #10
Frederick Gotham wrote:
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.
>

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.
Jul 21 '06 #11
In message <l9******************************@giganews.com>, Pete Becker
<pe********@acm.orgwrites
>Frederick Gotham wrote:
>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.
Shouldn't modal libraries be considered Evil?

--
Richard Herring
Jul 21 '06 #12
Richard Herring wrote:
In message <l9******************************@giganews.com>, Pete Becker
<pe********@acm.orgwrites
>Frederick Gotham wrote:
>>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.

Shouldn't modal libraries be considered Evil?
No.
Jul 21 '06 #13
In message <q6******************************@giganews.com>, Pete Becker
<pe********@acm.orgwrites
>Richard Herring wrote:
>In message <l9******************************@giganews.com>, Pete
Becker <pe********@acm.orgwrites
>>Frederick Gotham wrote:

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.
Shouldn't modal libraries be considered Evil?

No.
I was rather hoping to provoke more discussion than that ;-)

Global modes mean that if I link third-party code that uses this
library, it can alter the semantics of my code. Of course, I can protect
my code by wrapping it with appropriate constructs to preserve and
restore the mode, but there are costs in both program complexity and
runtime performance.

I need to be convinced that that's not a bad thing, or that the
alternatives are worse.

--
Richard Herring
Jul 24 '06 #14
Richard Herring wrote:
In message <q6******************************@giganews.com>, Pete Becker
<pe********@acm.orgwrites
>Richard Herring wrote:
>>In message <l9******************************@giganews.com>, Pete
Becker <pe********@acm.orgwrites

Frederick Gotham wrote:

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.

Shouldn't modal libraries be considered Evil?

No.


I was rather hoping to provoke more discussion than that ;-)
Then you should have said more. <g>
>
Global modes mean that if I link third-party code that uses this
library, it can alter the semantics of my code. Of course, I can protect
my code by wrapping it with appropriate constructs to preserve and
restore the mode, but there are costs in both program complexity and
runtime performance.

I need to be convinced that that's not a bad thing, or that the
alternatives are worse.
Sweeping generalizations are always wrong. Except this one.

The floating-point processor is modal. It has internal registers that
hold flags that tell it how to do things. The math libraries reflect
that design. Doing otherwise slows everything down.

Using modal resources correctly requires application-level design.
That's not inherently bad, but many programmers are uncomfortable with
it. They've heard the slogans about always solving problems in code, so
they write code with redundant low-level "safety" checks, lots of
setting and getting, and multiple short statements instead of terse,
tight code, then they rely on the mystical powers of the optimiser to
make the application acceptably fast and small. Sometimes it produces
something acceptable.

The right approach is not hacking in localized protection in case
someone does something wrong, but deciding how the application will use
that resource, and ensuring that that decision is followed. If that
means getting rid of a third-party library that doesn't play by the
rules, then get rid of it.
Jul 24 '06 #15

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

Similar topics

1
by: Lionel van den Berg | last post by:
Hi all, I'm having a problem porting from qt2.x to qt3.x. I have posted on a qt forum but no joy as yet so I thought that maybe someone here could shed some more light on what the compiler is...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
9
by: robbie.carlton | last post by:
Hello! I've programmed in c a bit, but nothing very complicated. I've just come back to it after a long sojourn in the lands of functional programming and am completely stumped on a very simple...
6
by: Yan | last post by:
Here is the code: class A {}; void (A::*A) (); // Line 3 int main() { A a; // Line 6 return 0; }
1
by: liuhaoran | last post by:
HI. i have a question about memory error. when i change double variable to float variable ,for example: int curGen = 0; double sum = 0; // m_iPopSize is int variable ,NewPop is a vector...
8
by: Jess | last post by:
Hi, I have a template function that triggered some compiler error. The abridged version of the class and function is: #include<memory> using namespace std; template <class T>
4
by: Stefano | last post by:
I have a couple of lines of a program that are making me mad. My intention is to run Internet Explorer in background. #include <windows.h> #include <stdio.h> int main () { char* strFunct =...
2
by: John | last post by:
I'm trying to install matplotlib and currently getting the below error. I searched the group and google and couldn't find anything similar... Any ideas? Thanks in advance! src/ft2font.cpp:...
3
by: Hill | last post by:
This is an simple map, just an exercise. Who can help me fix this compile issue?Thanks in advance. #include <string> #include <vector> #include <iostream> using std::vector; using std::string;...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.