Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
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

macrumors 68040
Oct 25, 2004
3,540
272
I think the file in which you are including this is being compiled with the C compiler, not the C++ compiler.
 

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
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

macrumors newbie
Sep 11, 2007
8
0
Denver
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.