Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ncoast.UUCP Path: utzoo!linus!decvax!cwruecmp!atvax!ncoast!bsa From: bsa@ncoast.UUCP (Brandon Allbery) Newsgroups: net.lang.c Subject: Re: What is setjmp... Clarification and typedef gripe Message-ID: <388@ncoast.UUCP> Date: Thu, 4-Oct-84 13:57:47 EDT Article-I.D.: ncoast.388 Posted: Thu Oct 4 13:57:47 1984 Date-Received: Fri, 5-Oct-84 20:45:13 EDT References: <> Reply-To: bsa@ncoast.UUCP (Brandon Allbery) Organization: North Coast XENIX, Cleveland Lines: 53 Summary: > Article <> > From: nazgul@apollo.uucp (Kee Hinckley) > Gary Mossquite rightly pointed > out that one ... should instead use the typedef "jmp_buf" sitting in: > > /usr/include/setjmp.h > > I agree with this whole-heartedly, the only thing that bugs me is > the way typedef works, which is essentially as a #define. For > example: > ----------------------------------------------------------------------- > #include > #include > > main() > { > jmp_buf foo, *tmp; > > tmp = &foo; > } > $ cc foo > > (0008) tmp = &foo; > ******** Line 8: Warning: Illegal pointer combination: incompatible types. > No errors, 1 warning, C Compiler, Rev 2.40 > ------------------------------------------------------------------------- > The error message may differ on your machine, but most compilers do at > least give some warning. The way around it: > tmp = (jmp_buf *) &foo; > works, but is rather frustrating. > > The whole point of a typedef (in my mind at least) is to create a > level of abstraction that alleviates the need to learn what the machine/ > compiler architecture actually looks like. To a certain degree typedef > seems to succeed at this, but then it all falls apart. Any thoughts? Yup. I think you may have found a compiler bug. Here on our humble Xenix machine, I get: ----------------------------------------- % cat jb.c #include main() {jmp_buf foo, *tmp; tmp = &foo;} % cc jb.c -o foobar # a.out is in use "jb.c", line 2: warning: & before array or function: ignored "jb.c", line 2: warning: illegal pointer combination, op = % ----------------------------------------- Typedef can't help it -- as long as jmp_buf is an array, you get this. Either we find a way to make it a struct, or we put up with it. But why doesn't your compiler report the *real* problem? (Or is it one?) --bsa