Re: [eigen] eigen3 migration

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


>> 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.

> That doesn't fix it as any use of the enum will break, like
> if(myComputation() == Success) // this is after including X.h

Would something goofy like

enum ComputationInfo {
#ifndef Success
 Success = 0,
#elif Success == 0
# undef Success
 Success = 0,
# define Success 0
#else
#  error "Success #defined with non-zero value"
#endif
 NumericalIssue = 1,
 NoConvergence = 2
};

work?  This works around any preceding '#define Success 0' macro by
'pushing/popping' its definition.  In the end, the token 'Success' will still
be macro expanded but ComputationInfo's enum will contain an entry for the
literal as well.  Finally, it loudly breaks if someone uses the wholly
incompatible '#define Success 1'.

- Rhys



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/