Re: ucontext_t wrong size if C++ headers included first?
Re: ucontext_t wrong size if C++ headers included first?
- Subject: Re: ucontext_t wrong size if C++ headers included first?
- From: Jean-Daniel Dupas <email@hidden>
- Date: Thu, 19 Sep 2013 21:25:35 +0200
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 <email@hidden> 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 (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
-- Jean-Daniel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden