Re: [eigen] eigen3 migration |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
Hi
Something like this
#include <GLee.h>
#define X_Success Success
#undef Success
namespace X11 {
enum X11Constants {
Success = X_Success
};
}
#undef X_Success
would still give you access to the X11 Success value, without clobbering
Eigen. You could put this in a "proxy-header" which first includes the
X.h (or GLee.h) and then does above manipulation.
The only problem this could cause are function-macros that you use and
that make use of Success themselves. Those you would need to wrap in
real inline functions in that header before you do that substitution;
something like:
#include <GLee.h>
#define X_foo foo
#undef foo
inline double foo(double x) { return X_foo(x); }
// see above...
HTH
Michael
On 04/14/2011 03:13 PM, ESCANDE Adrien 222264 wrote:
> Do you use X.h's Success yourself ?
> otherwise, a simple #undef Success before including Eigen would be enough (though it won't be an universal solution).
>
> Adrien
>
> -----Message d'origine-----
> De : Listengine [mailto:listengine@xxxxxxxxxxxxxxxxx] De la part de Benjamin Schindler
> Envoyé : jeudi 14 avril 2011 15:07
> À : eigen@xxxxxxxxxxxxxxxxxxx
> Objet : Re: [eigen] eigen3 migration
>
> On 04/14/2011 03:04 PM, Konstantin Tokarev wrote:
>>
>>
>> 14.04.2011, 16:54, "Jitse Niesen" <jitse@xxxxxxxxxxxxxxxxx>:
>>> On Wed, 13 Apr 2011, Benjamin Schindler wrote:
>>>
>>>> Okay, after deleting millions of lines of code, I managed to reduce it
>>>> to this:
>>>>
>>>> #define Success 0 /* everything's okay */
>>>> #include <eigen3/Eigen/Core>
>>>>
>>>> And this define comes from X.h, so it's rather standard
>>>
>>> It's pretty annoying that X.h has this #define. But I guess not including
>>> X.h is rather difficult.
>>>
>>> In Eigen3, Success is used as an enum constant to report that a
>>> computation was successful. The enum is defined as
>>>
>>> enum ComputationInfo {
>>> Success = 0,
>>> NumericalIssue = 1,
>>> NoConvergence = 2
>>> };
>>>
>>> We could rename Success to say ComputationSuccess, but that would break
>>> all user code that uses the Success constant. Perhaps an acceptable
>>> compromise would be to rename as above and also make Success available as
>>> an alternative name unless a Success macro already has been defined:
>>>
>>> enum ComputationInfo {
>>> ComputationSuccess = 0,
>>> #ifndef Success
>>> Success = 0,
>>> #endif
>>> NumericalIssue = 1,
>>> NoConvergence = 2
>>> };
>>>
>>> Any opinions?
>>
>> Require including of X.h after eigen3/Eigen/Core
>>
>
> That doesn't fix it as any use of the enum will break, like
>
> if(myComputation() == Success) // this is after including X.h
>
>
>
>
>