Quoting from /usr/include/setjmp.h
typedef struct __jmp_buf_tag /* C++ doesn't like tagless structs. */
{
/* NOTE: The machine-dependent definitions of `__sigsetjmp'
assume that a `jmp_buf' begins with a `__jmp_buf'.
Do not move this member or add others before it. */
__jmp_buf __jmpbuf; /* Calling environment. */
int __mask_was_saved; /* Saved the signal mask? */
__sigset_t __saved_mask; /* Saved signal mask. */
} jmp_buf[1];
i.e. - we are dealing with an array here. On Solaris, for example, the
definition is
#if defined(_LP64) || defined(_I32LPx)
typedef long jmp_buf[_JBLEN];
#else
typedef int jmp_buf[_JBLEN];
#endif
Even more clearly an array.
While it is ok to copy one builtin type to another, or one struct to
another, it is not ok to copy one array to another (in C++ish, no copy
constructors for arrays). And so, the compiler complains.
I hope this answers your question.
And to answer your UNASKED question - what do you do?
The answer (aside from the obvious "What do you want to mess around with
longjumps anyway") is - get around the need to copy. It is obvious from
the above example that you cannot trust jmp_buf to be a complete type.
It is not 100% clear to me whether copying sizeof(jmp_buf) bytes will
work on Linux, and whether it will also work on Solaris. Personally, I
would find a way around the need to copy (share pointers?), or around
the need to use long jumps at all.
Shachar
P.S.
What do you want to mess around with longjumps anyway?
Shaul Karl wrote:
>I have two 11 lines C programs which are supposed to be syntacticly similar.
>Yet int_test.c get compiled while the other does not:
>
>Script started on Mon Jul 2 14:51:10 2001
>[14:51:10 tmp]$ more *_test.c
>::::::::::::::
>int_test.c
>::::::::::::::
>
>#include <setjmp.h>
>
>int main()
>{
> int i;
> int *j = &i;
>
> i = *j;
> return 0;
>}
>::::::::::::::
>jmp_test.c
>::::::::::::::
>
>#include <setjmp.h>
>
>int main()
>{
> jmp_buf test_env;
> jmp_buf *test_env_p = &test_env;
>
> test_env = *test_env_p;
> return 0;
>}
>[14:51:25 tmp]$ cc -Wall -c int_test.c
>[14:51:47 tmp]$ cc -Wall -c jmp_test.c
>jmp_test.c: In function `main':
>jmp_test.c:9: incompatible types in assignment
>[14:51:56 tmp]$ exit
>exit
>
>Script done on Mon Jul 2 14:52:02 2001
>
>
>What did I miss?
>
=================================================================
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]