1 #ifndef __CURL_CURLRULES_H
2 #define __CURL_CURLRULES_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
25 /* ================================================================ */
26 /* COMPILE TIME SANITY CHECKS */
27 /* ================================================================ */
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.
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.
43 * Nothing in this file is intended to be modified or adjusted by the
44 * curl library user nor by the curl library builder.
46 * Do not deactivate any check, these are done to make sure that the
47 * library is properly built and used.
49 * You can find further help on the libcurl development mailing list:
50 * https://cool.haxx.se/mailman/listinfo/curl-library/
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:
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"
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.
75 * Verify that some macros are actually defined.
78 #ifndef CURL_SIZEOF_LONG
79 # error "CURL_SIZEOF_LONG definition is missing!"
80 Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing
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
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
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
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
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
108 #ifndef CURL_FORMAT_OFF_T
109 # error "CURL_FORMAT_OFF_T definition is missing!"
110 Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing
113 #ifndef CURL_SIZEOF_CURL_OFF_T
114 # error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
115 Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing
118 #ifndef CURL_SUFFIX_CURL_OFF_T
119 # error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
120 Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing
123 #ifndef CURL_SUFFIX_CURL_OFF_TU
124 # error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
125 Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing
129 * Macros private to this header file.
132 #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
134 #define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
137 * Verify that the size previously defined and expected for long
138 * is the same as the one reported by sizeof() at compile time.
143 [CurlchkszEQ(long, CURL_SIZEOF_LONG)];
146 * Verify that the size previously defined and expected for
147 * curl_off_t is actually the the same as the one reported
148 * by sizeof() at compile time.
153 [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
156 * Verify at compile time that the size of curl_off_t as reported
157 * by sizeof() is greater or equal than the one reported for long
158 * for the current compilation.
163 [CurlchkszGE(curl_off_t, long)];
166 * Verify that the size previously defined and expected for
167 * curl_socklen_t is actually the the same as the one reported
168 * by sizeof() at compile time.
173 [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)];
176 * Verify at compile time that the size of curl_socklen_t as reported
177 * by sizeof() is greater or equal than the one reported for int for
178 * the current compilation.
183 [CurlchkszGE(curl_socklen_t, int)];
185 /* ================================================================ */
186 /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
187 /* ================================================================ */
190 * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
191 * these to be visible and exported by the external libcurl interface API,
192 * while also making them visible to the library internals, simply including
193 * curl_setup.h, without actually needing to include curl.h internally.
194 * If some day this section would grow big enough, all this should be moved
195 * to its own header file.
199 * Figure out if we can use the ## preprocessor operator, which is supported
200 * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
201 * or __cplusplus so we need to carefully check for them too.
204 #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
205 defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
206 defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
208 /* This compiler is believed to have an ISO compatible preprocessor */
211 /* This compiler is believed NOT to have an ISO compatible preprocessor */
216 * Macros for minimum-width signed and unsigned curl_off_t integer constants.
219 #if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
220 # define __CURL_OFF_T_C_HLPR2(x) x
221 # define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
222 # define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
223 __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
224 # define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
225 __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
228 # define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
230 # define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
232 # define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
233 # define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
234 # define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
238 * Get rid of macros private to this header file.
245 * Get rid of macros not intended to exist beyond this point.
248 #undef CURL_PULL_WS2TCPIP_H
249 #undef CURL_PULL_SYS_TYPES_H
250 #undef CURL_PULL_SYS_SOCKET_H
251 #undef CURL_PULL_SYS_POLL_H
252 #undef CURL_PULL_STDINT_H
253 #undef CURL_PULL_INTTYPES_H
255 #undef CURL_TYPEOF_CURL_SOCKLEN_T
256 #undef CURL_TYPEOF_CURL_OFF_T
258 #ifdef CURL_NO_OLDIES
259 #undef CURL_FORMAT_OFF_T /* not required since 7.19.0 - obsoleted in 7.20.0 */
262 #endif /* __CURL_CURLRULES_H */