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