Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Sort of trivial code challenge - may be interesting to you anyway Date: Wed, 11 Mar 2026 13:49:43 -0700 Organization: None to speak of Lines: 90 Message-ID: <87zf4e147s.fsf@example.invalid> References: <10n80sc$3soe4$1@dont-email.me> <86ms0peby6.fsf@linuxsc.com> <10ockdh$3qpk6$1@dont-email.me> <10ocrjn$3qpk6$2@dont-email.me> <10od64s$3qpk6$4@dont-email.me> <86ikb9bmtw.fsf@linuxsc.com> <10oem5t$n5hk$1@dont-email.me> <86o6kz9zng.fsf@linuxsc.com> <10oi72k$1rss6$1@dont-email.me> <10oid0u$1u9aa$2@dont-email.me> <10ok1sl$2e7mc$1@dont-email.me> <10ok405$2f6sn$1@dont-email.me> <10ok7mt$2e7mc$5@dont-email.me> <10oking$2jsja$1@dont-email.me> <10onrkk$3s7id$2@dont-email.me> <87bjgv2ugg.fsf@example.invalid> <868qbya29e.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 11 Mar 2026 20:49:44 +0000 (UTC) Injection-Info: dont-email.me; posting-host="cdc5ea97d5e7028cbd6d638d06ccefec"; logging-data="1506802"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jJ0+GlBPpGow02ntHri+M" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:awxrI74hrDrxqqGQHYqmv+6Tahw= sha1:PU0lXtNb5+wyv70Kxgnf76AvIFE= Xref: csiph.com comp.lang.c:396913 Tim Rentsch writes: > Keith Thompson writes: >> scott@slp53.sl.home (Scott Lurndal) writes: >>> DFS writes: >>>> On 3/8/2026 3:29 PM, Bart wrote: >>>>> note that setjmp/longjmp are not functions >>>> >>>> huh? >>>> >>>> https://man7.org/linux/man-pages/man3/longjmp.3.html >>> >>> POSIX allows setjmp to be defined as a macro. >>> >>> https://pubs.opengroup.org/onlinepubs/9799919799/functions/setjmp.html >> >> More to the point, ISO C (all editions from C90 to C23) specifies that >> setjmp is a macro, and longjmp is a function. (Like any library >> function, longjmp can *also* be implemented as a macro). >> >> As it happens, glibc's has: >> >> #define setjmp(env) _setjmp (env) >> >> where _setjmp is a function. >> >> POSIX says: >> >> It is unspecified whether setjmp() is a macro or a function. If >> a macro definition is suppressed in order to access an actual >> function, or a program defines an external identifier with the >> name setjmp, the behavior is undefined. >> >> which may be inconsistent with ISO C. > > The original ANSI C standard says this: > > 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 a program > defines an external identifier with the name setjmp, the > behavior is undefined. > > I think every version of the ISO C standard says exactly the same > thing. I did a quick check but didn't verify that the wording is > exactly identical in every case. You're right, I missed that. The wording is consistent from ANSI C89 up to the latest draft of C2y. The first paragraph says: The header defines the macro setjmp, and declares one function and one type, for bypassing the normal function call and return discipline. C23 adds wording about the __STDC_VERSION_SETJMP_H__ macro. The third or fourth paragraph says: It is unspecified whether setjmp is a macro or an identifier declared with external linkage. If a macro definition is suppressed to access an actual function, or a program defines an external identifier with the name setjmp, the behavior is undefined. Any standard library function may optionally be implemented as a macro. setjmp is different in that an implementation is allowed to define it only as a function, only as a macro, or both. Since the first paragraph clearly *and incorrectly* refers to "the macro setjmp", I didn't read the rest. I suggest it should say "the macro or function setjmp". For this program: #include #include int main(void) { #ifdef setjmp puts("setjmp is defined as a macro"); #else puts("setjmp is not defined"); #endif return 0; } a conforming hosted implementation could print either message. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */