Floor() doesn't exist ??

J

john.leidel

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?
 
K

kingfox

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.
 
M

Michael Brennan

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
 
A

Army1987

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.
 
J

john.leidel

`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 :)
 
C

Christopher Benson-Manica

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top