fred@mindcraft.com (Fred Zlotnick) (03/16/91)
I'm having trouble understanding what the C standard requires of setjmp(). Section 4.6 starts out with The header <setjmp.h> defines the macro setjmp and declares one function [longjmp] and one type [jmp_buf] ... This would seem to imply that setjmp() must be implemented as a macro on a conforming implementation. However, later in the same section, it states It is unspecified whether setjmp is a macro or an identifier with external linkage. This seems to imply the opposite: that the implementor has a choice. The rationale doesn't help much. So what is the consensus of the newsgroup, and of the C standard experts therein? One system in our lab that claims ANSI C conformance has a <setjmp.h> that includes lines like these: #if __STDC__ == 1 extern int setjmp(jmp_buf env); #define setjmp(X) setjmp(X) #endif Another system in our lab, also claiming ANSI conformance, has the prototype but not the macro. Clearly I'm not the only one who's confused. Note that, as Chuck Karish has pointed out to me, this has implications for POSIX.1. In that standard it states (8.3.1.2) that The sigsetjmp() macro shall comply with the definition of the setjmp() macro in the C Standard. ---- Fred Zlotnick | #include <std.disclaimer> fred@mindcraft.com | #include <brilliant.quote> ...!{decwrl,ames,hpda}!mindcrf!fred |
torek@elf.ee.lbl.gov (Chris Torek) (03/16/91)
In article <669072342.15719@mindcraft.com> fred@mindcraft.com (Fred Zlotnick) writes: > It is unspecified whether setjmp is a macro or an identifier > with external linkage. This is the correct statement of the two. The first one is really meant to imply that the programmer must not assume that setjmp() is a `real function'. -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov
gwyn@smoke.brl.mil (Doug Gwyn) (03/17/91)
In article <669072342.15719@mindcraft.com> fred@mindcraft.com (Fred Zlotnick) writes: > It is unspecified whether setjmp is a macro or an identifier > with external linkage. That's the correct answer. In the third public review, X3J11 responded to the observation that setjmp (despite the note at the beginning of section 4.6) is not *necessarily* a macro as follows: The intent is clear, and better wording would complicate the document unnecessarily.