Can't compile overloaded class operator wth TNT include

Discussion in 'Mac Programming' started by ScKaSx, Sep 27, 2007.

  1. ScKaSx macrumors regular

    Feb 27, 2006
    Hi All,

    I am trying to use the TNT (template numerical toolkit) include files in some of my C++ code. In one of the files the class operator 'sign' is overloaded:

    "inline double sign(double a)
    return (a > 0 ? 1.0 : -1.0);

    inline float sign(float a)
    return (a > 0.0 ? 1.0f : -1.0f);

    When I try to use this include my compiler (g++ from command line) gives the following error:

    /usr/include/tnt/tntmath.h: In function 'float TNT::sign(float)':
    /usr/include/tnt/tntmath.h:65: error: declaration of C function 'float TNT::sign(float)' conflicts with
    /usr/include/tnt/tntmath.h:58: error: previous declaration 'double TNT::sign(double)' here

    Any ideas?

  2. iSee macrumors 68040


    Oct 25, 2004
    I think the file in which you are including this is being compiled with the C compiler, not the C++ compiler.
  3. ScKaSx thread starter macrumors regular

    Feb 27, 2006
    iSee, thanks for the response. So I moved the tnt files to the local directory of my program and don't have that problem anymore (not that all of my problems are solved, however).

    To get this straight, does that mean g++ doesn't look in the same path as gcc? And if this is the case, how can I configure g++ as to where to look for include files?

  4. thealtered7 macrumors newbie

    Sep 11, 2007
    You can pass directories to g++ when compiling from the command line. I can't recall the exact option to specify, read the man pages.
    Else, you could put the libraries you are using directly within the c++ include folder buried deep within the Developer directory.

Share This Page