Portable uses of jmpbuf's
wsmith at m.cs.uiuc.edu
wsmith at m.cs.uiuc.edu
Wed Oct 12 06:12:00 AEST 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 at cs.uiuc.edu
More information about the Comp.lang.c
mailing list