Edouard@340
|
1 |
#ifndef __CURL_CURLRULES_H
|
Edouard@340
|
2 |
#define __CURL_CURLRULES_H
|
Edouard@340
|
3 |
/***************************************************************************
|
Edouard@340
|
4 |
* _ _ ____ _
|
Edouard@340
|
5 |
* Project ___| | | | _ \| |
|
Edouard@340
|
6 |
* / __| | | | |_) | |
|
Edouard@340
|
7 |
* | (__| |_| | _ <| |___
|
Edouard@340
|
8 |
* \___|\___/|_| \_\_____|
|
Edouard@340
|
9 |
*
|
Edouard@340
|
10 |
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
|
Edouard@340
|
11 |
*
|
Edouard@340
|
12 |
* This software is licensed as described in the file COPYING, which
|
Edouard@340
|
13 |
* you should have received as part of this distribution. The terms
|
Edouard@340
|
14 |
* are also available at http://curl.haxx.se/docs/copyright.html.
|
Edouard@340
|
15 |
*
|
Edouard@340
|
16 |
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
Edouard@340
|
17 |
* copies of the Software, and permit persons to whom the Software is
|
Edouard@340
|
18 |
* furnished to do so, under the terms of the COPYING file.
|
Edouard@340
|
19 |
*
|
Edouard@340
|
20 |
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
Edouard@340
|
21 |
* KIND, either express or implied.
|
Edouard@340
|
22 |
*
|
Edouard@340
|
23 |
***************************************************************************/
|
Edouard@340
|
24 |
|
Edouard@340
|
25 |
/* ================================================================ */
|
Edouard@340
|
26 |
/* COMPILE TIME SANITY CHECKS */
|
Edouard@340
|
27 |
/* ================================================================ */
|
Edouard@340
|
28 |
|
Edouard@340
|
29 |
/*
|
Edouard@340
|
30 |
* NOTE 1:
|
Edouard@340
|
31 |
* -------
|
Edouard@340
|
32 |
*
|
Edouard@340
|
33 |
* All checks done in this file are intentionally placed in a public
|
Edouard@340
|
34 |
* header file which is pulled by curl/curl.h when an application is
|
Edouard@340
|
35 |
* being built using an already built libcurl library. Additionally
|
Edouard@340
|
36 |
* this file is also included and used when building the library.
|
Edouard@340
|
37 |
*
|
Edouard@340
|
38 |
* If compilation fails on this file it is certainly sure that the
|
Edouard@340
|
39 |
* problem is elsewhere. It could be a problem in the curlbuild.h
|
Edouard@340
|
40 |
* header file, or simply that you are using different compilation
|
Edouard@340
|
41 |
* settings than those used to build the library.
|
Edouard@340
|
42 |
*
|
Edouard@340
|
43 |
* Nothing in this file is intended to be modified or adjusted by the
|
Edouard@340
|
44 |
* curl library user nor by the curl library builder.
|
Edouard@340
|
45 |
*
|
Edouard@340
|
46 |
* Do not deactivate any check, these are done to make sure that the
|
Edouard@340
|
47 |
* library is properly built and used.
|
Edouard@340
|
48 |
*
|
Edouard@340
|
49 |
* You can find further help on the libcurl development mailing list:
|
Edouard@340
|
50 |
* http://cool.haxx.se/mailman/listinfo/curl-library/
|
Edouard@340
|
51 |
*
|
Edouard@340
|
52 |
* NOTE 2
|
Edouard@340
|
53 |
* ------
|
Edouard@340
|
54 |
*
|
Edouard@340
|
55 |
* Some of the following compile time checks are based on the fact
|
Edouard@340
|
56 |
* that the dimension of a constant array can not be a negative one.
|
Edouard@340
|
57 |
* In this way if the compile time verification fails, the compilation
|
Edouard@340
|
58 |
* will fail issuing an error. The error description wording is compiler
|
Edouard@340
|
59 |
* dependent but it will be quite similar to one of the following:
|
Edouard@340
|
60 |
*
|
Edouard@340
|
61 |
* "negative subscript or subscript is too large"
|
Edouard@340
|
62 |
* "array must have at least one element"
|
Edouard@340
|
63 |
* "-1 is an illegal array size"
|
Edouard@340
|
64 |
* "size of array is negative"
|
Edouard@340
|
65 |
*
|
Edouard@340
|
66 |
* If you are building an application which tries to use an already
|
Edouard@340
|
67 |
* built libcurl library and you are getting this kind of errors on
|
Edouard@340
|
68 |
* this file, it is a clear indication that there is a mismatch between
|
Edouard@340
|
69 |
* how the library was built and how you are trying to use it for your
|
Edouard@340
|
70 |
* application. Your already compiled or binary library provider is the
|
Edouard@340
|
71 |
* only one who can give you the details you need to properly use it.
|
Edouard@340
|
72 |
*/
|
Edouard@340
|
73 |
|
Edouard@340
|
74 |
/*
|
Edouard@340
|
75 |
* Verify that some macros are actually defined.
|
Edouard@340
|
76 |
*/
|
Edouard@340
|
77 |
|
Edouard@340
|
78 |
#ifndef CURL_SIZEOF_LONG
|
Edouard@340
|
79 |
# error "CURL_SIZEOF_LONG definition is missing!"
|
Edouard@340
|
80 |
Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing
|
Edouard@340
|
81 |
#endif
|
Edouard@340
|
82 |
|
Edouard@340
|
83 |
#ifndef CURL_TYPEOF_CURL_SOCKLEN_T
|
Edouard@340
|
84 |
# error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!"
|
Edouard@340
|
85 |
Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing
|
Edouard@340
|
86 |
#endif
|
Edouard@340
|
87 |
|
Edouard@340
|
88 |
#ifndef CURL_SIZEOF_CURL_SOCKLEN_T
|
Edouard@340
|
89 |
# error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!"
|
Edouard@340
|
90 |
Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing
|
Edouard@340
|
91 |
#endif
|
Edouard@340
|
92 |
|
Edouard@340
|
93 |
#ifndef CURL_TYPEOF_CURL_OFF_T
|
Edouard@340
|
94 |
# error "CURL_TYPEOF_CURL_OFF_T definition is missing!"
|
Edouard@340
|
95 |
Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing
|
Edouard@340
|
96 |
#endif
|
Edouard@340
|
97 |
|
Edouard@340
|
98 |
#ifndef CURL_FORMAT_CURL_OFF_T
|
Edouard@340
|
99 |
# error "CURL_FORMAT_CURL_OFF_T definition is missing!"
|
Edouard@340
|
100 |
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing
|
Edouard@340
|
101 |
#endif
|
Edouard@340
|
102 |
|
Edouard@340
|
103 |
#ifndef CURL_FORMAT_CURL_OFF_TU
|
Edouard@340
|
104 |
# error "CURL_FORMAT_CURL_OFF_TU definition is missing!"
|
Edouard@340
|
105 |
Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing
|
Edouard@340
|
106 |
#endif
|
Edouard@340
|
107 |
|
Edouard@340
|
108 |
#ifndef CURL_FORMAT_OFF_T
|
Edouard@340
|
109 |
# error "CURL_FORMAT_OFF_T definition is missing!"
|
Edouard@340
|
110 |
Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing
|
Edouard@340
|
111 |
#endif
|
Edouard@340
|
112 |
|
Edouard@340
|
113 |
#ifndef CURL_SIZEOF_CURL_OFF_T
|
Edouard@340
|
114 |
# error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
|
Edouard@340
|
115 |
Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing
|
Edouard@340
|
116 |
#endif
|
Edouard@340
|
117 |
|
Edouard@340
|
118 |
#ifndef CURL_SUFFIX_CURL_OFF_T
|
Edouard@340
|
119 |
# error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
|
Edouard@340
|
120 |
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing
|
Edouard@340
|
121 |
#endif
|
Edouard@340
|
122 |
|
Edouard@340
|
123 |
#ifndef CURL_SUFFIX_CURL_OFF_TU
|
Edouard@340
|
124 |
# error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
|
Edouard@340
|
125 |
Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing
|
Edouard@340
|
126 |
#endif
|
Edouard@340
|
127 |
|
Edouard@340
|
128 |
/*
|
Edouard@340
|
129 |
* Macros private to this header file.
|
Edouard@340
|
130 |
*/
|
Edouard@340
|
131 |
|
Edouard@340
|
132 |
#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
|
Edouard@340
|
133 |
|
Edouard@340
|
134 |
#define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
|
Edouard@340
|
135 |
|
Edouard@340
|
136 |
/*
|
Edouard@340
|
137 |
* Verify that the size previously defined and expected for long
|
Edouard@340
|
138 |
* is the same as the one reported by sizeof() at compile time.
|
Edouard@340
|
139 |
*/
|
Edouard@340
|
140 |
|
Edouard@340
|
141 |
typedef char
|
Edouard@340
|
142 |
__curl_rule_01__
|
Edouard@340
|
143 |
[CurlchkszEQ(long, CURL_SIZEOF_LONG)];
|
Edouard@340
|
144 |
|
Edouard@340
|
145 |
/*
|
Edouard@340
|
146 |
* Verify that the size previously defined and expected for
|
Edouard@340
|
147 |
* curl_off_t is actually the the same as the one reported
|
Edouard@340
|
148 |
* by sizeof() at compile time.
|
Edouard@340
|
149 |
*/
|
Edouard@340
|
150 |
|
Edouard@340
|
151 |
typedef char
|
Edouard@340
|
152 |
__curl_rule_02__
|
Edouard@340
|
153 |
[CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
|
Edouard@340
|
154 |
|
Edouard@340
|
155 |
/*
|
Edouard@340
|
156 |
* Verify at compile time that the size of curl_off_t as reported
|
Edouard@340
|
157 |
* by sizeof() is greater or equal than the one reported for long
|
Edouard@340
|
158 |
* for the current compilation.
|
Edouard@340
|
159 |
*/
|
Edouard@340
|
160 |
|
Edouard@340
|
161 |
typedef char
|
Edouard@340
|
162 |
__curl_rule_03__
|
Edouard@340
|
163 |
[CurlchkszGE(curl_off_t, long)];
|
Edouard@340
|
164 |
|
Edouard@340
|
165 |
/*
|
Edouard@340
|
166 |
* Verify that the size previously defined and expected for
|
Edouard@340
|
167 |
* curl_socklen_t is actually the the same as the one reported
|
Edouard@340
|
168 |
* by sizeof() at compile time.
|
Edouard@340
|
169 |
*/
|
Edouard@340
|
170 |
|
Edouard@340
|
171 |
typedef char
|
Edouard@340
|
172 |
__curl_rule_04__
|
Edouard@340
|
173 |
[CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)];
|
Edouard@340
|
174 |
|
Edouard@340
|
175 |
/*
|
Edouard@340
|
176 |
* Verify at compile time that the size of curl_socklen_t as reported
|
Edouard@340
|
177 |
* by sizeof() is greater or equal than the one reported for int for
|
Edouard@340
|
178 |
* the current compilation.
|
Edouard@340
|
179 |
*/
|
Edouard@340
|
180 |
|
Edouard@340
|
181 |
typedef char
|
Edouard@340
|
182 |
__curl_rule_05__
|
Edouard@340
|
183 |
[CurlchkszGE(curl_socklen_t, int)];
|
Edouard@340
|
184 |
|
Edouard@340
|
185 |
/* ================================================================ */
|
Edouard@340
|
186 |
/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
|
Edouard@340
|
187 |
/* ================================================================ */
|
Edouard@340
|
188 |
|
Edouard@340
|
189 |
/*
|
Edouard@340
|
190 |
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
Edouard@340
|
191 |
* these to be visible and exported by the external libcurl interface API,
|
Edouard@340
|
192 |
* while also making them visible to the library internals, simply including
|
Edouard@340
|
193 |
* curl_setup.h, without actually needing to include curl.h internally.
|
Edouard@340
|
194 |
* If some day this section would grow big enough, all this should be moved
|
Edouard@340
|
195 |
* to its own header file.
|
Edouard@340
|
196 |
*/
|
Edouard@340
|
197 |
|
Edouard@340
|
198 |
/*
|
Edouard@340
|
199 |
* Figure out if we can use the ## preprocessor operator, which is supported
|
Edouard@340
|
200 |
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
Edouard@340
|
201 |
* or __cplusplus so we need to carefully check for them too.
|
Edouard@340
|
202 |
*/
|
Edouard@340
|
203 |
|
Edouard@340
|
204 |
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
Edouard@340
|
205 |
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
Edouard@340
|
206 |
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
Edouard@340
|
207 |
defined(__ILEC400__)
|
Edouard@340
|
208 |
/* This compiler is believed to have an ISO compatible preprocessor */
|
Edouard@340
|
209 |
#define CURL_ISOCPP
|
Edouard@340
|
210 |
#else
|
Edouard@340
|
211 |
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
Edouard@340
|
212 |
#undef CURL_ISOCPP
|
Edouard@340
|
213 |
#endif
|
Edouard@340
|
214 |
|
Edouard@340
|
215 |
/*
|
Edouard@340
|
216 |
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
Edouard@340
|
217 |
*/
|
Edouard@340
|
218 |
|
Edouard@340
|
219 |
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
Edouard@340
|
220 |
# define __CURL_OFF_T_C_HLPR2(x) x
|
Edouard@340
|
221 |
# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
|
Edouard@340
|
222 |
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
Edouard@340
|
223 |
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
Edouard@340
|
224 |
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
|
Edouard@340
|
225 |
__CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
Edouard@340
|
226 |
#else
|
Edouard@340
|
227 |
# ifdef CURL_ISOCPP
|
Edouard@340
|
228 |
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
Edouard@340
|
229 |
# else
|
Edouard@340
|
230 |
# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
Edouard@340
|
231 |
# endif
|
Edouard@340
|
232 |
# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
|
Edouard@340
|
233 |
# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
Edouard@340
|
234 |
# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
Edouard@340
|
235 |
#endif
|
Edouard@340
|
236 |
|
Edouard@340
|
237 |
/*
|
Edouard@340
|
238 |
* Get rid of macros private to this header file.
|
Edouard@340
|
239 |
*/
|
Edouard@340
|
240 |
|
Edouard@340
|
241 |
#undef CurlchkszEQ
|
Edouard@340
|
242 |
#undef CurlchkszGE
|
Edouard@340
|
243 |
|
Edouard@340
|
244 |
/*
|
Edouard@340
|
245 |
* Get rid of macros not intended to exist beyond this point.
|
Edouard@340
|
246 |
*/
|
Edouard@340
|
247 |
|
Edouard@340
|
248 |
#undef CURL_PULL_WS2TCPIP_H
|
Edouard@340
|
249 |
#undef CURL_PULL_SYS_TYPES_H
|
Edouard@340
|
250 |
#undef CURL_PULL_SYS_SOCKET_H
|
Edouard@340
|
251 |
#undef CURL_PULL_SYS_POLL_H
|
Edouard@340
|
252 |
#undef CURL_PULL_STDINT_H
|
Edouard@340
|
253 |
#undef CURL_PULL_INTTYPES_H
|
Edouard@340
|
254 |
|
Edouard@340
|
255 |
#undef CURL_TYPEOF_CURL_SOCKLEN_T
|
Edouard@340
|
256 |
#undef CURL_TYPEOF_CURL_OFF_T
|
Edouard@340
|
257 |
|
Edouard@340
|
258 |
#ifdef CURL_NO_OLDIES
|
Edouard@340
|
259 |
#undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */
|
Edouard@340
|
260 |
#endif
|
Edouard@340
|
261 |
|
Edouard@340
|
262 |
#endif /* __CURL_CURLRULES_H */
|