Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
18.c.limits.stdcxx-988.cpp
Go to the documentation of this file.
1
29#include <cassert>
30#include <limits.h>
31
32
33int main ()
34{
35#if (defined __unix__ || defined __unix || defined unix) \
36 && !defined _RWSTD_EDG_ECCP
37
38 // According to POSIX (SUSv3), the following macros are required
39 // to be defined in <limits.h> (others, such as OPEN_MAX) are
40 // optional):
41 // http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
42
43 // Runtime Increasable Values
44
45 // The magnitude limitations in the following list shall be fixed
46 // by specific implementations. An application should assume that
47 // the value supplied by <limits.h> in a specific implementation
48 // is the minimum that pertains whenever the application is run
49 // under that implementation. A specific instance of a specific
50 // implementation may increase the value relative to that supplied
51 // by <limits.h> for that implementation. The actual value supported
52 // by a specific instance shall be provided by the sysconf() function.
53
54 assert (BC_BASE_MAX != 0 /* >= _POSIX2_BC_BASE_MAX */ );
55 assert (BC_DIM_MAX != 0 /* >= _POSIX2_BC_DIM_MAX */ );
56 assert (BC_SCALE_MAX != 0 /* >= _POSIX2_BC_SCALE_MAX */ );
57 assert (BC_STRING_MAX != 0 /* >= _POSIX2_BC_STRING_MAX */ );
58 assert (CHARCLASS_NAME_MAX != 0 /* >= _POSIX2_CHARCLASS_NAME_MAX */ );
59 assert (COLL_WEIGHTS_MAX != 0 /* >= _POSIX2_COLL_WEIGHTS_MAX */ );
60 assert (EXPR_NEST_MAX != 0 /* >= _POSIX2_EXPR_NEST_MAX */ );
61 assert (LINE_MAX != 0 /* >= _POSIX2_LINE_MAX */ );
62 assert (NGROUPS_MAX != 0 /* >= _POSIX_NGROUPS_MAX */ );
63 assert (RE_DUP_MAX != 0 /* >= _POSIX2_RE_DUP_MAX */ );
64
65 // Minimum Values
66
67 // The symbolic constants in the following list shall be defined
68 // in <limits.h> with the values shown. These are symbolic names
69 // for the most restrictive value for certain features on an
70 // implementation conforming to this volume of IEEE Std 1003.1-2001.
71 // Related symbolic constants are defined elsewhere in this volume
72 // of IEEE Std 1003.1-2001 which reflect the actual implementation
73 // and which need not be as restrictive. A conforming implementation
74 // shall provide values at least this large. A strictly conforming
75 // application must not require a larger value for correct operation.
76
77 // avoid testing specific values since they're not important here
78 // all we care is that the macros be defined (i.e., that thet are
79 // not somehow hidden or #undef'd by our implementation)
80
81 assert (_POSIX_ARG_MAX != 0 /* == 4096 */);
82 assert (_POSIX_CHILD_MAX != 0 /* == 25 */);
83 assert (_POSIX_HOST_NAME_MAX != 0 /* == 255 */);
84 assert (_POSIX_LINK_MAX != 0 /* == 8 */);
85 assert (_POSIX_LOGIN_NAME_MAX != 0 /* == 9 */);
86 assert (_POSIX_MAX_CANON != 0 /* == 255 */);
87 assert (_POSIX_MAX_INPUT != 0 /* == 255 */);
88 assert (_POSIX_NAME_MAX != 0 /* == 14 */);
89 assert (_POSIX_NGROUPS_MAX != 0 /* == 8 */);
90 assert (_POSIX_OPEN_MAX != 0 /* == 20 */);
91 assert (_POSIX_PATH_MAX != 0 /* == 256 */);
92 assert (_POSIX_PIPE_BUF != 0 /* == 512 */);
93 assert (_POSIX_RE_DUP_MAX != 0 /* == 255 */);
94 assert (_POSIX_SSIZE_MAX != 0 /* == 32767 */);
95 assert (_POSIX_STREAM_MAX != 0 /* == 8 */);
96 assert (_POSIX_SYMLINK_MAX != 0 /* == 255 */);
97 assert (_POSIX_SYMLOOP_MAX != 0 /* == 8 */);
98 assert (_POSIX_TTY_NAME_MAX != 0 /* == 9 */);
99 assert (_POSIX_TZNAME_MAX != 0 /* == 6 */);
100
101# ifdef _POSIX2_VERSION
102
103 assert (_POSIX2_BC_BASE_MAX != 0 /* == 99 */);
104 assert (_POSIX2_BC_DIM_MAX != 0 /* == 2048 */);
105 assert (_POSIX2_BC_SCALE_MAX != 0 /* == 99 */);
106 assert (_POSIX2_BC_STRING_MAX != 0 /* == 1000 */);
107 assert (_POSIX2_CHARCLASS_NAME_MAX != 0 /* == 14 */);
108 assert (_POSIX2_COLL_WEIGHTS_MAX != 0 /* == 2 */);
109 assert (_POSIX2_EXPR_NEST_MAX != 0 /* == 32 */);
110 assert (_POSIX2_LINE_MAX != 0 /* == 2048 */);
111 assert (_POSIX2_RE_DUP_MAX != 0 /* == 255 */);
112
113# endif // _POSIX2_VERSION
114
115#endif // UNIX && !EDG eccp
116
117 // Numerical Limits
118
119 // The values in the following lists shall be defined in <limits.h>
120 // and are constant expressions suitable for use in #if preprocessing
121 // directives. Moreover, except for {CHAR_BIT}, {DBL_DIG}, {DBL_MAX},
122 // {FLT_DIG}, {FLT_MAX}, {LONG_BIT}, {WORD_BIT}, and {MB_LEN_MAX},
123 // the symbolic names are defined as expressions of the correct type.
124
125 // If the value of an object of type char is treated as a signed
126 // integer when used in an expression, the value of {CHAR_MIN} is
127 // the same as that of {SCHAR_MIN} and the value of {CHAR_MAX} is
128 // the same as that of {SCHAR_MAX}. Otherwise, the value of
129 // {CHAR_MIN} is 0 and the value of {CHAR_MAX} is the same as that
130 // of {UCHAR_MAX}.
131
132 assert (CHAR_BIT == 8);
134 assert (CHAR_MIN == SCHAR_MIN || CHAR_MIN == 0);
135 assert (INT_MAX >= 2147483647);
136 assert (LONG_MAX >= +2147483647);
137 assert (MB_LEN_MAX >= 1);
138 assert (SCHAR_MAX == +127);
139 assert (SHRT_MAX >= +32767);
140
141#if !defined (_RWSTD_EDG_ECCP) && !defined (_MSC_VER)
142
143 // avoid exercising with the EDG eccp front end (strict mode)
144 assert (LONG_BIT >= 32);
145 assert (SSIZE_MAX >= _POSIX_SSIZE_MAX);
146 assert (WORD_BIT >= 32);
147
148#endif // EDG eccp || MSVC || ICC/Windows
149
150 assert (UCHAR_MAX >= 255);
151 assert (UINT_MAX >= 4294967295);
152 assert (ULONG_MAX >= 4294967295);
153 assert (USHRT_MAX >= 65535);
154 assert (INT_MIN <= -2147483647);
155 assert (LONG_MIN != 0);
156 assert (SCHAR_MIN == -128);
157 assert (SHRT_MIN != 0);
158
159#ifndef _RWSTD_NO_LONG_LONG
160
161# if !defined __HP_aCC || 199901L <= __STDC_VERSION__
162
163 // HP aCC defines LLONG_MAX and LLONG_MIN only in C99 mode
164 // i.e., with -AC99
165
166 assert (LLONG_MIN != 0);
167 assert (LLONG_MAX >= +9223372036854775807LL);
168 assert (ULLONG_MAX >= 18446744073709551615ULL);
169
170# endif
171
172#endif // _RWSTD_NO_LONG_LONG
173
174 return 0;
175}
#define assert(expr)
Definition _cassert.h:40
#define SHRT_MAX
Definition limits.h:64
#define INT_MIN
Definition limits.h:80
#define CHAR_BIT
Definition limits.h:40
#define UCHAR_MAX
Definition limits.h:60
#define ULONG_MAX
Definition limits.h:96
#define LONG_MAX
Definition limits.h:88
#define CHAR_MIN
Definition limits.h:48
#define USHRT_MAX
Definition limits.h:72
#define CHAR_MAX
Definition limits.h:44
#define MB_LEN_MAX
Definition limits.h:100
#define SCHAR_MAX
Definition limits.h:52
#define INT_MAX
Definition limits.h:76
#define SCHAR_MIN
Definition limits.h:56
#define UINT_MAX
Definition limits.h:84
#define SHRT_MIN
Definition limits.h:68
#define LONG_MIN
Definition limits.h:92