autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_C_NORETURN macro?


From: Bruno Haible
Subject: Re: AC_C_NORETURN macro?
Date: Sun, 29 Apr 2012 16:19:35 +0200
User-agent: KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; )

Vincent Lefevre wrote:
> modules/snippet/_Noreturn references build-aux/snippet/_Noreturn.h,
> which is:
> 
> #ifndef _Noreturn
> # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
>       || 0x5110 <= __SUNPRO_C)
> #  define _Noreturn __attribute__ ((__noreturn__))
> # elif 1200 <= _MSC_VER
> #  define _Noreturn __declspec (noreturn)
> # else
> #  define _Noreturn
> # endif
> #endif
> 
> but I don't see how it can be correct on a non-GCC non-SunPro C11
> implementation: _Noreturn would get defined to nothing; the code
> would be valid, but the C11 _Noreturn function specifier would not
> be used.

If we get to know a different compiler which support _Noreturn but
does not have a working <stdnoreturn.h> file, we can add it to the
#ifs here.

> I had changed the MPFR code to:
> ...
> #if defined(MPFR_HAVE_NORETURN)
> /* _Noreturn is specified by ISO C11 (Section 6.7.4);
>    in GCC, it is supported as of version 4.7. */
> # define MPFR_NORETURN _Noreturn
> #elif __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
> # define MPFR_NORETURN __attribute__ ((noreturn))
> #else
> # define MPFR_NORETURN
> #endif
>
> I think that something like
> 
> #elif 1200 <= _MSC_VER
> # define MPFR_NORETURN __declspec (noreturn)
> 
> could be added.

Sure. What you do here is reasonable. However, for gnulib the goal is
different: In programs that use gnulib we don't want to have the user
(developer) to learn new set of macros, different from what ISO C or
POSIX specify. Rather, we want the user to be able to use *exactly*
the syntax that is specified in ISO C or POSIX. And it happens that
the task of defining a MPFR_NORETURN macro that works like 'noreturn'
is an easier task than to define a 'noreturn' macro. The reason is that
with MSVC, the compiler wants to see   __declspec (noreturn)  but this is
hardly possible if 'noreturn' is at the same time defined as a macro without
arguments.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]