[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 01/19] * m4/gnulib-common.m4 (gl_COMMON_BODY): Add _Noreturn.
From: |
Bruno Haible |
Subject: |
Re: [PATCH 01/19] * m4/gnulib-common.m4 (gl_COMMON_BODY): Add _Noreturn. |
Date: |
Tue, 12 Jul 2011 01:27:28 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Paul,
> > it looks to me that the ISO C and ISO C++ committees need to
> > do some more work to align the syntaxes.
>
> This is pretty unlikely. They won't converge here,
> just as they didn't converge with 'bool'.
Huh? 'bool' is usable the same way in C and C++, with only minor semantic
differences. But with 'noreturn', programmers need to write
extern
#ifdef __cplusplus
[[noreturn]]
#else
noreturn
#endif
void foo (int);
> The _Noreturn / <stdnoreturn.h> part of draft C1X has been present
> in multiple drafts; I think it's reasonably safe to start tracking
> it at this point.
I'm still not so sure. _Noreturn has been there for some time, yes. But
<stdnoreturn.h> and 'noreturn' have been introduced after n1548.pdf
(dated 2010-12-02). And also on the C++ side, there seem to have been
discussions around the use of the brackets less than a year ago.
In the current state,
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3288.htm>
implies that defining 'noreturn' as a macro will be invalid in C++.
But that's exactly what ISO C <stdnoreturn.h> does. Therefore IMO
in the gnulib module description for this module we must clearly mention
that this header file cannot be used in C++.
> My patch prefers _Noreturn when it can, for two reasons:
>
> * In contexts like lib/stdlib.in.h, it reduces namespace pollution.
>
> * It removes a dependency on the stdnoreturn module.
Good. And it also avoids problems with C++ and with MS compilers.
> if these files (namely, openat.h,
> sigpipe-die.h, xalloc.h, xmemdup0.h, xstrtol.h) are not intended
> to be copied elsewhere, it'd be better to be consistent and to
> have them use _Noreturn as well; that way, their modules wouldn't
> need to depend on the stdnoreturn module.
Generally, all gnulib header files that are meant to be possibly copied
elsewhere use "#if @HAVE_...@" instead of "#if HAVE_...", and have mechanics
to incorporate the contents of build-aux/arg-nonnull.h, build-aux/c++defs.h,
build-aux/unused-parameter.h, build-aux/warn-on-use.h, as needed. For this
reason, they are all called *.in.h.
openat.h, sigpipe-die.h, xalloc.h, xmemdup0.h, xstrtol.h are all meant to
reside only in a source tree of a package that uses gnulib. They can rely
on _Noreturn directly (from gnulib-common.m4).
I would prefer if these files could use '_Noreturn' as well, for consistency,
and to avoid problems in mixed C / C++ packages (such as gettext and Octave).
Bruno
--
In memoriam Zahra Kazemi <http://en.wikipedia.org/wiki/Zahra_Kazemi>
Re: [PATCH 01/19] * m4/gnulib-common.m4 (gl_COMMON_BODY): Add _Noreturn., Ben Pfaff, 2011/07/11