Mail Archives: djgpp-workers/1998/06/23/03:28:47
On Tue, 23 Jun 1998, Morten Welinder wrote:
> If I recall correctly, setjmp should be a macro, not a library function.
It amazes me time and again how many subtle points can the ANSI C
Standard have, even for somebody who uses the language for a long
time...
Here's what ANSI C says about this:
7.6 Nonlocal jumps <setjmp.h>
....
It is unspecified whether `setjmp' is a macro or an identifier
declared with external linkage. If a macro definition is suppressed
in order to access an actual function, or if a program defines an
external identifier with the name `setjmp', the behavior is
undefined.
The Standard then goes on referencing `setjmp' as ``the setjmp macro''
throughout the rest of the text ;-).
P.J. Plauger's ``The Standard C Library'' explains that defining a
function `setjmp' and a macro with that same name is a way to ensure
that no program declares `setjmp' if it includes <setjmp.h>, and no
program defines its own function `setjmp', even if it doesn't include
<setjmp.h>.
So it seems that either macro or function is okay, and if we want to
accept Plauger's suggestion, then adding something like the following
to <setjmp.h> should be enough:
#define setjmp(foo) setjmp(foo)
I suggest to add this line. Comments?
- Raw text -