Re: ucontext_t wrong size if C++ headers included first?
Such macro MUST be defined before inclusion of any header. Moreover it should be defined to the value 600.
From http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
“An XSI-conforming application should ensure that the feature test macro _XOPEN_SOURCE is defined with the value 600 before inclusion of any header. ” Le 19 sept. 2013 à 20:08, Sidney San Martín <sidney@s4y.us> a écrit :
Check out this C++ program:
// #include <iostream>
#define _XOPEN_SOURCE 1 #include <ucontext.h>
int main () { printf("sizeof(ucontext_t) -> %ld\n", sizeof(ucontext_t)); }
On my machine, it prints "768" (big ol' CPU). But, if I uncomment "#include <iostream>" and recompile, it prints "56". In practice, this makes getcontext() and the like overrun ucontext_t structs and stomp on other memory.
If I define _XOPEN_SOURCE *before* I include iostream, ucontext_t is the right size. What's going on here? _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-dev/devlists%40shadowlab.org
This email sent to devlists@shadowlab.org
-- Jean-Daniel _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.app... This email sent to site_archiver@lists.apple.com
participants (1)
-
Jean-Daniel Dupas