1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
6
<title>Autoconf Macro: ac_need_stdint_h</title>
7
<link rel="stylesheet" type="text/css" href="ac-archive.css">
11
<table summary="web navigation" style="width:100%;">
14
<td style="width:50%;" align="center">[<a href="index.html">Macro Index
17
<td style="width:50%;" align="center">[<a href=
18
"../m4source/ac_need_stdint_h.m4">Download M4 Source</a>]</td>
24
<h1>ac_need_stdint_h</h1>
29
<p style="text-align:left; white-space:nowrap;"><code>AC_NEED_STDINT_H [(
30
HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]</code></p>
36
<p>obsoleted - superseded by AC_CREATE_STDINT_H</p>
38
<p>the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
39
existence of an include file <stdint.h> that defines a set of
40
typedefs, especially uint8_t,int32_t,uintptr_t. Many older installations
41
will not provide this file, but some will have the very same definitions in
42
<inttypes.h>. In other enviroments we can use the inet-types in
43
<sys/types.h> which would define the typedefs int8_t and u_int8_t
46
<p>This macros will create a local "stdint.h" if it cannot find the global
47
<stdint.h> (or it will create the headerfile given as an argument).
48
In many cases that file will just have a singular "#include
49
<inttypes.h>" statement, while in other environments it will provide
50
the set of basic stdint's defined:
51
int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
52
int_least32_t.. int_fast32_t.. intmax_t which may or may not rely on the
53
definitions of other files, or using the AC_COMPILE_CHECK_SIZEOF macro to
54
determine the actual sizeof each type.</p>
56
<p>if your header files require the stdint-types you will want to create an
57
installable file package-stdint.h that all your other installable header
58
may include. So if you have a library package named "mylib", just use</p>
60
AC_NEED_STDINT(zziplib-stdint.h)
63
<p>in configure.in and go to install that very header file in Makefile.am
64
along with the other headers (mylib.h) - and the mylib-specific headers can
65
simply use "#include <mylib-stdint.h>" to obtain the
68
<p>Remember, if the system already had a valid <stdint.h>, the
69
generated file will include it directly. No need for fuzzy HAVE_STDINT_H
76
<p>1.5 (last modified: 2003-02-02)</p>
82
<p>Guido Draheim <guidod@gmx.de></p>
85
<h2>M4 Source Code</h2>
88
<pre class="m4source">
89
AC_DEFUN([AC_NEED_STDINT_H],
90
[AC_MSG_CHECKING([for stdint-types])
91
ac_cv_header_stdint="no-file"
92
ac_cv_header_stdint_u="no-file"
93
for i in $1 inttypes.h sys/inttypes.h sys/int_types.h stdint.h ; do
94
AC_CHECK_TYPEDEF_(uint32_t, $i, [ac_cv_header_stdint=$i])
96
for i in $1 sys/types.h inttypes.h sys/inttypes.h sys/int_types.h ; do
97
AC_CHECK_TYPEDEF_(u_int32_t, $i, [ac_cv_header_stdint_u=$i])
99
dnl debugging: __AC_MSG( !$ac_cv_header_stdint!$ac_cv_header_stdint_u! ...)
101
ac_stdint_h=`echo ifelse($1, , stdint.h, $1)`
102
if test "$ac_cv_header_stdint" != "no-file" ; then
103
if test "$ac_cv_header_stdint" != "$ac_stdint_h" ; then
104
AC_MSG_RESULT(found in $ac_cv_header_stdint)
105
echo "#include <$ac_cv_header_stdint>" >$ac_stdint_h
106
AC_MSG_RESULT(creating $ac_stdint_h - (just to include $ac_cv_header_stdint) )
108
AC_MSG_RESULT(found in $ac_stdint_h)
110
ac_cv_header_stdint_generated=false
111
elif test "$ac_cv_header_stdint_u" != "no-file" ; then
112
AC_MSG_RESULT(found u_types in $ac_cv_header_stdint_u)
113
if test $ac_cv_header_stdint = "$ac_stdint_h" ; then
114
AC_MSG_RESULT(creating $ac_stdint_h - includes $ac_cv_header_stdint, expect problems!)
116
AC_MSG_RESULT(creating $ac_stdint_h - (include inet-types in $ac_cv_header_stdint_u and re-typedef))
118
echo "#ifndef __AC_STDINT_H" >$ac_stdint_h
119
echo "#define __AC_STDINT_H" '"'$ac_stdint_h'"' >>$ac_stdint_h
120
echo "#ifndef _GENERATED_STDINT_H" >>$ac_stdint_h
121
echo "#define _GENERATED_STDINT_H" '"'$PACKAGE $VERSION'"' >>$ac_stdint_h
122
cat >>$ac_stdint_h <<EOF
124
#include <stddef.h>
125
#include <$ac_cv_header_stdint_u>
127
/* int8_t int16_t int32_t defined by inet code */
128
typedef u_int8_t uint8_t;
129
typedef u_int16_t uint16_t;
130
typedef u_int32_t uint32_t;
132
/* it's a networkable system, but without any stdint.h */
133
/* hence it's an older 32-bit system... (a wild guess that seems to work) */
134
typedef u_int32_t uintptr_t;
135
typedef int32_t intptr_t;
137
ac_cv_header_stdint_generated=true
139
AC_MSG_RESULT(not found, need to guess the types now... )
140
AC_COMPILE_CHECK_SIZEOF(long, 32)
141
AC_COMPILE_CHECK_SIZEOF(void*, 32)
142
AC_MSG_RESULT( creating $ac_stdint_h - using detected values for sizeof long and sizeof void* )
143
echo "#ifndef __AC_STDINT_H" >$ac_stdint_h
144
echo "#define __AC_STDINT_H" '"'$ac_stdint_h'"' >>$ac_stdint_h
145
echo "#ifndef _GENERATED_STDINT_H" >>$ac_stdint_h
146
echo "#define _GENERATED_STDINT_H" '"'$PACKAGE $VERSION'"' >>$ac_stdint_h
147
cat >>$ac_stdint_h <<EOF
149
/* ISO C 9X: 7.18 Integer types <stdint.h> */
151
#define __int8_t_defined
152
typedef signed char int8_t;
153
typedef unsigned char uint8_t;
154
typedef signed short int16_t;
155
typedef unsigned short uint16_t;
158
if test "$ac_cv_sizeof_long" = "64" ; then
159
cat >>$ac_stdint_h <<EOF
161
typedef signed int int32_t;
162
typedef unsigned int uint32_t;
163
typedef signed long int64_t;
164
typedef unsigned long uint64_t;
165
#define int64_t int64_t
166
#define uint64_t uint64_t
170
cat >>$ac_stdint_h <<EOF
172
typedef signed long int32_t;
173
typedef unsigned long uint32_t;
177
if test "$ac_cv_sizeof_long" != "$ac_cv_sizeof_voidp" ; then
178
cat >>$ac_stdint_h <<EOF
180
typedef signed int intptr_t;
181
typedef unsigned int uintptr_t;
184
cat >>$ac_stdint_h <<EOF
186
typedef signed long intptr_t;
187
typedef unsigned long uintptr_t;
189
ac_cv_header_stdint_generated=true
193
if "$ac_cv_header_stdint_generated" ; then
194
cat >>$ac_stdint_h <<EOF
196
typedef int8_t int_least8_t;
197
typedef int16_t int_least16_t;
198
typedef int32_t int_least32_t;
200
typedef uint8_t uint_least8_t;
201
typedef uint16_t uint_least16_t;
202
typedef uint32_t uint_least32_t;
204
typedef int8_t int_fast8_t;
205
typedef int32_t int_fast16_t;
206
typedef int32_t int_fast32_t;
208
typedef uint8_t uint_fast8_t;
209
typedef uint32_t uint_fast16_t;
210
typedef uint32_t uint_fast32_t;
212
typedef long int intmax_t;
213
typedef unsigned long uintmax_t;
229
<a href="COPYING.html">GNU General Public License</a> with this special
230
<a href="COPYING-Exception.html">exception</a>.