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."


-- 
Nadav Har'El                        |      Monday, Jul  2 2001, 11 Tammuz 5761
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Experience is what causes a person to
http://nadav.harel.org.il           |make new mistakes instead of old ones.

=================================================================
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]

Reply via email to