On Mon, Jul 02, 2001 at 03:00:21PM +0300, 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?

I don't think you are supposed to assign jmp_buf, only to use it with 
setjmp() and longjmp(). It is not a basic compiler type -- it is a 
system type defined by your libc and/or your OS and there are no 
guarantees about its definition IIRC. Specifically glibc defines 
jmpbuf as a 1-size array of a struct (so that calls to functions will 
only pass a pointer, I suppose), and the "incompatible type" error is 
what gcc gives you when you try to assign to an array.

If you really want to assign to an array or to any other type, you can 
always wrap them with a struct, or simply memcpy(). But if you are trying 
to do that you are probably doing something wrong. What are you after?

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