On Mon, Jul 02, 2001 at 03:32:24PM +0300, Nadav Har'El wrote:
> On Mon, Jul 02, 2001, Shaul Karl wrote about "(main_buf = *main_buf_p) is not
>syntacticly like (i = *j) ?":
> > #include <setjmp.h>
> >
> > int main()
> > {
> > jmp_buf test_env;
> > jmp_buf *test_env_p = &test_env;
> >
> > test_env = *test_env_p;
> > return 0;
> > }
> > jmp_test.c:9: incompatible types in assignment
> >
> > What did I miss?
>
> Well, the problem is the definition of jmp_buf: in Linux,
> typedef struct ... jmp_buf[1];
>
> Which means the jmp_buf type is an array. In C you can't normally assign
> arrays like you did (because C thinks you're trying to assign pointers, rather
> than the content of the array), so either do
> *test_env=**test_env_p;
>
> (to assign the first element, but this is highly dependent on the linux
> implementation),
>
> or the more portable (and thus better) approach is to use memcpy() to copy a
> jmp_buf.
>
> BTW, don't forget the following "NOTES" from the Linux setjmp() manual:
> "setjmp() and sigsetjmp make programs hard to understand
> and maintain. If possible an alternative should be used."
BTW: if we're already talking about setjmp(), longjmp() and difficulty to
understand, has anyone read the article from the GNU Pth source
distribution? It deals with applications of setjmp() and similar calls in
thread implementations, and I found it fascinatingly mindboggling.
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]