Reply to topic

Bug Reports How To? +A small inconvenience w/ short var name

tobi_s
Registered Member
Posts
2
Karma
0
Hi,

thanks for Eigen, I use it all the time. Since I ran into a small bug / compatibility issue recently, I wanted to submit this as a small contribution. Turns out, all paths lead to the bugzilla page, but one cannot submit a bug report without an account. Obtaining an account requires writing an e-mail to the core developers' list "if needed." Now besides being unclear (when do I "need" it?), I could of course send my bug report to the core developers directly, so this procedure strikes me as awkward from the user's perspective. I really don't know if that's the intended procedure or not.

My bug report is fairly simple: SVD/BDCSVD.h uses (as is common in linalg code) very short variable names, U and V in particular. Microsoft likes wrapping strings in macros in order to provide wide character support. Their cpprestsdk defines "U" for that purpose. So in a project that uses both one gets, depending of the precise order of includes, lots of warnings of the form ...

eigen\src/SVD/BDCSVD.h(949): warning C4002: too many actual parameters for macro 'U'

... or hard errors if one bumps into a combination where that template is actually expanded.

Shortest example reproducing the problem:
Code: Select all
#define U(x)
#include <Eigen/Dense>


A possible solution that neither makes the calculation unreadable nor collides with the macro:
Code: Select all
#ifdef U
#define EIGEN_INTERNAL_U_PROTECTOR U
#undef U
#endif
... code ...
#ifdef EIGEN_INTERNAL_U_PROTECTOR
#define U EIGEN_INTERNAL_U_PROTECTOR
#undef EIGEN_INTERNAL_U_PROTECTOR
#endif

or any variation thereof.
User avatar ggael
Moderator
Posts
3430
Karma
19
OS
well, the main problem is that defining macro with such generic and short name is really stupid in the first place. Todays its U, tomorrow will V or whatever else, so I'm not that much willing to protect all our variables and functions about all possible poorly crafted library in the world... Is that so problematic to #include the header is the right order?
tobi_s
Registered Member
Posts
2
Karma
0
Well, I cannot disagree with that, but I will point out that there are at best 52 single-letter macros that one would need to guard against at trivial cost, and it would only have to be done once.

 
Reply to topic

Bookmarks



Who is online

Registered users: atelierrosa, Baidu [Spider], Bing [Bot], bionan, Capitain_Jack, claydoh, Exabot [Bot], Google [Bot], johssw, philippg, Sogou [Bot], TheraHedwig, Yahoo [Bot]