Floor() doesn't exist ??

Discussion in 'C Programming' started by john.leidel@gmail.com, May 12, 2007.

  1. Guest

    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?
    , May 12, 2007
    #1
    1. Advertising

  2. kingfox Guest

    On 5ÔÂ12ÈÕ, ÏÂÎç10ʱ02·Ö, 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.
    kingfox, May 12, 2007
    #2
    1. Advertising

  3. On 2007-05-12, <> 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?
    >
    Michael Brennan, May 12, 2007
    #3
  4. Army1987 Guest

    <> ha scritto nel messaggio
    news:...
    > 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?
    >
    Army1987, May 12, 2007
    #4
  5. Guest

    On May 12, 10:04 am, "Army1987" <> wrote:
    > <> ha scritto nel messaggionews:...> 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 :)
    , May 12, 2007
    #5
  6. 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.
    Christopher Benson-Manica, May 14, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SpaceCowboy
    Replies:
    6
    Views:
    1,071
    Josef Garvi
    Aug 15, 2003
  2. John
    Replies:
    3
    Views:
    334
    Chris Smith
    Feb 11, 2005
  3. Y.S.
    Replies:
    3
    Views:
    984
    strajan
    Sep 17, 2003
  4. LT
    Replies:
    7
    Views:
    2,072
    Phlip
    Jul 25, 2004
  5. Markus Mohr
    Replies:
    7
    Views:
    228
    Thomas 'PointedEars' Lahn
    Nov 28, 2003
Loading...

Share This Page