[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Openexr-devel] Include Conflicts
From: |
Paul Schneider |
Subject: |
Re: [Openexr-devel] Include Conflicts |
Date: |
Thu, 3 Jun 2004 15:39:45 -0700 |
Does nr.h declare a function called pow? Even worse, does it #define a
macro named pow? That will certainly conflict with the versions of pow
in the standard C library (<numeric>) and in the Imath library
(ImathMath.h).
Imath puts pow in the Imath namespace, and <numeric> puts pow in the
std namespace, so there is no conflict. My guess is that the Numerical
Recipies is defining a third pow() that doesn't play well with the
other two. You can probably just get rid of the NR definition, or put
it in its own namespace.
Another possible problem is that if you have something like this:
using namespace std:
using namespace Imath;
float f = pow (2, 3);
the compiler won't know whether you meant std::pow or Imath::pow.
Watch out for that.
PS - Imath declares its own version of pow() to make sure that the
right function gets called on systems that support both pow() and
powf(). You wouldn't want to promote a float to a double if your
system has fast single-precision floating-point routines.
On Jun 3, 2004, at 3:28 PM, Brian Clark wrote:
Is anyone out there by any chance using code from the Numerical
Recipes in C++ book? I just tried to add some of their code to a
project with my OpenEXR libraries, and there seems to be a conflict.
If I #include <nr.h> to my Image class which also has half.h,
ImfArray.h and ImfRgbaFile.h, I get an error about ambiguous
definitions of functions. One such example is
static float pow(float x,float y) in the file ImathMath.h.
But if I move the #includes around, there are functions in <complex>
that have the same problem. I'm not even using <complex>, but it's
included in the nr.h file that is included in all the Numerical
Recipes .cpp files (and I don't think the functions I'm using are
using <complex>).
I have used OpenEXR libraries in the past (this same file) before
adding the NR includes. I have used the NR includes in a simple
project where I just tested the NR libraries to see if they did what I
wanted, and there was no problem. It's only when I put them together.
It's possible I just have a setting wrong in Xcode (I'm on OSX
10.3.3), which is why I want to check if anyone out there has been
able to use them together. I will also say that it's possible I'm
going about including things the wrong way--I'm not experienced with
tying other people's code into my projects.
Failing having a setting or include order that someone can tell me
from their experience, I guess I can just go through the nr.h code and
comment out any libraries that I don't need for this project. That
may be a whole new can of worms in messing with other dependencies--I
don't know. I've never done anything like that before.
Comments? Bueller? Bueller? Bueller?
Brian
_______________________________________________
Openexr-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/openexr-devel