Registered Member
|
Trying to use Eigen on Cygwin, I got a compiler error about posix_memalign() being undeclared. I traced the problem to the file Eigen/src/Core/util/Memory.h, which uses this preprocessor code to test for the availability of that function:
This fails because posix_memalign() is in an optional section of Posix, so testing for _XOPEN_SOURCE (or _GNU_SOURCE) doesn't necessarily mean that it's available. Cygwin uses Newlib, which doesn't include it. I recommend correcting the test by checking for the relevant feature test macro:
Although in theory this even simpler version should be enough:
|
Registered Member
|
Thanks a lot for finding and fixing this bug! I'm applying your change right now.
Except that I'm keeping the (defined _XOPEN_SOURCE) because, as far as I understand, the standard doesn't guarantee that undefined symbols are treated as 0 even though most compilers do that.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Hi,
your test "#if (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))" could still go wrong, if _XOPEN_SOURCE is defined without a value. On a Mac (10.6.3 with default gcc 4.2.1), I get a compile error, if I include Eigen/Core and _XOPEN_SOURCE is defined without a value: /usr/local/include/Eigen/src/Core/util/Memory.h:69:70: error: operator '>=' has no left operand I suggest you change the test to: #if (defined _GNU_SOURCE) || ((_XOPEN_SOURCE + 0) >= 600)) This compiles cleanly, even if _XOPEN_SOURCE is defined without a value... Markus |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]