PDA

View Full Version : Can't compile overloaded class operator wth TNT include




ScKaSx
Sep 27, 2007, 04:26 PM
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?

Thanks,
ScKaSx



iSee
Sep 27, 2007, 10:02 PM
I think the file in which you are including this is being compiled with the C compiler, not the C++ compiler.

ScKaSx
Sep 28, 2007, 03:42 PM
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?

Cheesrs

thealtered7
Sep 28, 2007, 05:07 PM
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.