1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>
Autoconf Macro: qef_c_noreturn
</title>
<link rel="stylesheet" type="text/css" href="ac-archive.css">
</head>
<body>
<table summary="web navigation" style="width:100%;">
<tbody>
<tr>
<td style="width:50%;" align="center">
<a href="http://autoconf-archive.cryp.to/qef_c_noreturn.m4">Download M4
Source</a>
</td>
<td style="width:50%;" align="center">
<a href="macros-by-category.html">Macro Index Page</a>
</td>
</tr>
</tbody>
</table>
<hr>
<h1>
qef_c_noreturn
</h1>
<h2>
Obsolete Macro
</h2>
<p class="indent">
Test "__GNUC__+0 >= 2 && __GNUC_MINOR__+0 >= 5" instead.
</p>
<h2>
Synopsis
</h2>
<p class="indent" style="white-space:nowrap;">
<code>QEF_C_NORETURN</code>
</p>
<h2>
Description
</h2>
<div class="indent">
<p>
Check if we can use GCC's __noreturn__ attribute in prototypes to indicate
that functions never return. This can be used by the compiler to do some
extra optimizations.
</p>
<p>
FUNCATTR_NORETURN is defined as what we should put at the end of function
prototypes to achieve this. If the compiler doesn't support it then it is
defined as empty.
</p>
<p>
An example of a a function's prototype and implementation using this macro:
</p>
<pre>
void this_function_never_returns (void) FUNCATTR_NORETURN;
void this_function_never_returns (void) {
exit (0);
}
</pre>
</div>
<h2>
Author
</h2>
<p class="indent">
Geoff Richards <ctzgpr@scs.leeds.ac.uk>
</p>
<h2>
Last Modified
</h2>
<p class="indent">
2005-01-23
</p>
<h2>
M4 Source Code
</h2>
<div class="indent">
<pre class="m4source">
AC_DEFUN([QEF_C_NORETURN],
[AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether the C compiler (${CC-cc}) accepts noreturn attribute)
AC_CACHE_VAL(qef_cv_c_noreturn,
[qef_cv_c_noreturn=no
AC_TRY_COMPILE(
[#include <stdio.h>
void f (void) __attribute__ ((noreturn));
void f (void)
{
exit (1);
}
], [
f ();
],
[qef_cv_c_noreturn="yes"; FUNCATTR_NORETURN_VAL="__attribute__ ((noreturn))"],
[qef_cv_c_noreturn="no"; FUNCATTR_NORETURN_VAL="/* will not return */"])
])
AC_MSG_RESULT($qef_cv_c_noreturn)
AC_DEFINE_UNQUOTED(FUNCATTR_NORETURN, $FUNCATTR_NORETURN_VAL)
])dnl
</pre>
</div>
</body>
</html>
|