[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (main_buf = *main_buf_p) is not syntacticly like (i = *j) ?
- To: Shaul Karl <shaulka(at-nospam)bezeqint.net>
- Subject: Re: (main_buf = *main_buf_p) is not syntacticly like (i = *j) ?
- From: "Nadav Har'El" <nyh(at-nospam)math.technion.ac.il>
- Date: Mon, 2 Jul 2001 15:32:24 +0300
- Cc: linux-il(at-nospam)linux.org.il
- Delivered-To: linux.org.il-linux-il@linux.org.il
- Hebrew-Date: 11 Tammuz 5761
- In-Reply-To: <E15H2NP-0002sn-00@rakefet>; from shaulka@bezeqint.net on Mon, Jul 02, 2001 at 03:00:21PM +0300
- References: <E15H2NP-0002sn-00@rakefet>
- Sender: linux-il-bounce(at-nospam)cs.huji.ac.il
- User-Agent: Mutt/1.2i
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
nyh@math.technion.ac.il |-----------------------------------------
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 linux-il-request@linux.org.il with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail linux-il-request@linux.org.il