Path: utzoo!attcan!uunet!husc6!uwvax!oddjob!tank!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!m.cs.uiuc.edu!wsmith From: wsmith@m.cs.uiuc.edu Newsgroups: comp.lang.c Subject: Re: Portable uses of jmpbuf's Message-ID: <4700023@m.cs.uiuc.edu> Date: 11 Oct 88 20:12:00 GMT References: <4700022@m.cs.uiuc.edu> Lines: 31 Nf-ID: #R:m.cs.uiuc.edu:4700022:m.cs.uiuc.edu:4700023:000:1313 Nf-From: m.cs.uiuc.edu!wsmith Oct 11 15:12:00 1988 >/* ---------- "Portable uses of jmpbuf's" ---------- */ >How do you portably pass a jmpbuf as a parameter to a C function? > >Some machines define a jmpbuf to be struct { stuff } , while >others define a jmpbuf to be an array. In one case, an & is required, >while in the other case it is not. > >My best solution was to define my own structure with one field of a >jmpbuf and then always take the address. > >Is there a better way? Here is a more detailed description of the problem: If I have a function that I want to pass the address of a jmpbuf to it, with "typedef struct {} jmpbuf;", the call to the function will be "function(&a_jmpbuf);" and the prototype ala Microsoft C will be "function( jmpbuf * a );" With "typedef int jmpbuf[10];", the call to the function will be "function(a_jmpbuf);" and the prototype will be "function( jmpbuf a );" because the array gets converted into a pointer to its first element when I make the call. If I try to make the prototype "function( jmpbuf * a) ;", the call will no longer match even if make the call be the same as with the struct version of jmpbuf. I have heard that one fix is to wait for an ANSI compatible compiler which will allow "function(&a_jmpbuf);" and "function(jmpbuf * a);" in either case. Bill Smith uiucdcs!wsmith wsmith@cs.uiuc.edu