Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Floor() doesn't exist ??

Reply
Thread Tools

Floor() doesn't exist ??

 
 
john.leidel@gmail.com
Guest
Posts: n/a
 
      05-12-2007
In doing some work on a library I'm writing, I'm trying to use the
`floor()` function to get the largest integral value of a variable.
I'm compiling everything using the mpich mpicc built with gcc 4.1.0
[standard build with OpenSuse 10.1]. For some reason, it doesn't like
my floor function :

mrng.c:137: error: called object 'floor' is not a function

I've included the correct <math.h>

The code is pretty simplistic :

ran->max_num = floor( td );

both `ran->max_num` and `td` are double values.

I wrote a *very* simple test program to see if it would find 'floor'
and it worked.
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char **argv )
{
printf( "%s%f\n", "FLOOR OF 2.3 :: ", floor( 2.3 ) );

return 0;
}

Any thoughts why this is happening?

 
Reply With Quote
 
 
 
 
kingfox
Guest
Posts: n/a
 
      05-12-2007
On 5月12日, 下午10时02分, (E-Mail Removed) wrote:
> In doing some work on a library I'm writing, I'm trying to use the
> `floor()` function to get the largest integral value of a variable.
> I'm compiling everything using the mpich mpicc built with gcc 4.1.0
> [standard build with OpenSuse 10.1]. For some reason, it doesn't like
> my floor function :
>
> mrng.c:137: error: called object 'floor' is not a function
>
> I've included the correct <math.h>
>
> The code is pretty simplistic :
>
> ran->max_num = floor( td );
>
> both `ran->max_num` and `td` are double values.
>
> I wrote a *very* simple test program to see if it would find 'floor'
> and it worked.
> #include <stdio.h>
> #include <stdlib.h>
> int main( int argc, char **argv )
> {
> printf( "%s%f\n", "FLOOR OF 2.3 :: ", floor( 2.3 ) );
>
> return 0;
>
> }
>
> Any thoughts why this is happening?


I think maybe you should post more code which can cause the error
message.

 
Reply With Quote
 
 
 
 
Michael Brennan
Guest
Posts: n/a
 
      05-12-2007
On 2007-05-12, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> In doing some work on a library I'm writing, I'm trying to use the
> `floor()` function to get the largest integral value of a variable.
> I'm compiling everything using the mpich mpicc built with gcc 4.1.0
> [standard build with OpenSuse 10.1]. For some reason, it doesn't like
> my floor function :
>
> mrng.c:137: error: called object 'floor' is not a function
>

I'd guess you have something declared with the name floor after
your #include <math.h> line. Could be a variable or something that
is not a function. If you turn up your warning level your compiler
will probably detect that.

> I've included the correct <math.h>
>
> The code is pretty simplistic :
>
> ran->max_num = floor( td );
>
> both `ran->max_num` and `td` are double values.
>
> I wrote a *very* simple test program to see if it would find 'floor'
> and it worked.
> #include <stdio.h>
> #include <stdlib.h>

Here you should have included math.h instead of stdlib.h
> int main( int argc, char **argv )
> {
> printf( "%s%f\n", "FLOOR OF 2.3 :: ", floor( 2.3 ) );
>
> return 0;
> }
>
> Any thoughts why this is happening?
>


 
Reply With Quote
 
Army1987
Guest
Posts: n/a
 
      05-12-2007

<(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed) oups.com...
> In doing some work on a library I'm writing, I'm trying to use the
> `floor()` function to get the largest integral value of a variable.
> I'm compiling everything using the mpich mpicc built with gcc 4.1.0
> [standard build with OpenSuse 10.1]. For some reason, it doesn't like
> my floor function :
>
> mrng.c:137: error: called object 'floor' is not a function

Maybe there's something else named 'floor' declared in an inner
block...
> I've included the correct <math.h>

Some compilers don't automatically link some functions from
<math.h>. You have to tell them to do that (e.g. for gcc use the
switch -lm). But if the test below does work I don't think this is
your case.

> The code is pretty simplistic :
>
> ran->max_num = floor( td );
>
> both `ran->max_num` and `td` are double values.
>
> I wrote a *very* simple test program to see if it would find 'floor'
> and it worked.
> #include <stdio.h>
> #include <stdlib.h>
> int main( int argc, char **argv )
> {
> printf( "%s%f\n", "FLOOR OF 2.3 :: ", floor( 2.3 ) );
>
> return 0;
> }
>
> Any thoughts why this is happening?
>



 
Reply With Quote
 
john.leidel@gmail.com
Guest
Posts: n/a
 
      05-12-2007
On May 12, 10:04 am, "Army1987" <(E-Mail Removed)> wrote:
> <(E-Mail Removed)> ha scritto nel messaggionews:1178978552.299097.311060@u30g2000hsc .googlegroups.com...> In doing some work on a library I'm writing, I'm trying to use the
> > `floor()` function to get the largest integral value of a variable.
> > I'm compiling everything using the mpich mpicc built with gcc 4.1.0
> > [standard build with OpenSuse 10.1]. For some reason, it doesn't like
> > my floor function :

>
> > mrng.c:137: error: called object 'floor' is not a function

>
> Maybe there's something else named 'floor' declared in an inner
> block...> I've included the correct <math.h>
>
> Some compilers don't automatically link some functions from
> <math.h>. You have to tell them to do that (e.g. for gcc use the
> switch -lm). But if the test below does work I don't think this is
> your case.
>
> > The code is pretty simplistic :

>
> > ran->max_num = floor( td );

>
> > both `ran->max_num` and `td` are double values.

>
> > I wrote a *very* simple test program to see if it would find 'floor'
> > and it worked.
> > #include <stdio.h>
> > #include <stdlib.h>
> > int main( int argc, char **argv )
> > {
> > printf( "%s%f\n", "FLOOR OF 2.3 :: ", floor( 2.3 ) );

>
> > return 0;
> > }

>
> > Any thoughts why this is happening?



AHA!! Sorry everyone... I had not yet consumed enough coffee this
morning... The function from which I was having trouble was defined
as :

extern MRNG *m_init_mrng( MPI_Comm RCOMM,
RNG_T type,
RNG_OPT_T options,
int mem,
double seed,
double floor,
double ceil,
int extend )

I can't use `floor` and 'ceil` as variable defs!!! ARG!!

Problem is fixed

 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      05-14-2007
(E-Mail Removed) wrote:

> I can't use `floor` and 'ceil` as variable defs!!! ARG!!


Don't you mean "ARGC!!!"?

(You can name variables "floor" and "ceil" if you want, just not when
you include <math.h> directly or indirectly.)

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Celeron Centrino Exist? Silverstrand Front Page News 0 10-24-2005 11:13 PM
Does my object exist? So why its HWND doesn't exist? That's a question... (CMonthCalCtrl control) LT C++ 7 07-25-2004 07:08 PM
Can the Favourites Sidebar (IE, Opera, etc.) be addressed selectively (exist or non-exist)? Markus Mohr Javascript 7 11-28-2003 12:20 AM
In Schema, how to say "If one element exist, another element must exist"? Y.S. XML 3 09-17-2003 02:51 PM
Help:Why can't I use namespace System.Web? It is said that this namespace doesn't exist. But it should exist. 三光 ASP .Net 1 07-29-2003 04:31 PM



Advertisments