michael@0: #ifndef __CURL_CURLRULES_H michael@0: #define __CURL_CURLRULES_H michael@0: /*************************************************************************** michael@0: * _ _ ____ _ michael@0: * Project ___| | | | _ \| | michael@0: * / __| | | | |_) | | michael@0: * | (__| |_| | _ <| |___ michael@0: * \___|\___/|_| \_\_____| michael@0: * michael@0: * Copyright (C) 1998 - 2009, Daniel Stenberg, , et al. michael@0: * michael@0: * This software is licensed as described in the file COPYING, which michael@0: * you should have received as part of this distribution. The terms michael@0: * are also available at http://curl.haxx.se/docs/copyright.html. michael@0: * michael@0: * You may opt to use, copy, modify, merge, publish, distribute and/or sell michael@0: * copies of the Software, and permit persons to whom the Software is michael@0: * furnished to do so, under the terms of the COPYING file. michael@0: * michael@0: * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY michael@0: * KIND, either express or implied. michael@0: * michael@0: * $Id: curlrules.h,v 1.7 2009-10-27 16:56:20 yangtse Exp $ michael@0: ***************************************************************************/ michael@0: michael@0: /* ================================================================ */ michael@0: /* COMPILE TIME SANITY CHECKS */ michael@0: /* ================================================================ */ michael@0: michael@0: /* michael@0: * NOTE 1: michael@0: * ------- michael@0: * michael@0: * All checks done in this file are intentionally placed in a public michael@0: * header file which is pulled by curl/curl.h when an application is michael@0: * being built using an already built libcurl library. Additionally michael@0: * this file is also included and used when building the library. michael@0: * michael@0: * If compilation fails on this file it is certainly sure that the michael@0: * problem is elsewhere. It could be a problem in the curlbuild.h michael@0: * header file, or simply that you are using different compilation michael@0: * settings than those used to build the library. michael@0: * michael@0: * Nothing in this file is intended to be modified or adjusted by the michael@0: * curl library user nor by the curl library builder. michael@0: * michael@0: * Do not deactivate any check, these are done to make sure that the michael@0: * library is properly built and used. michael@0: * michael@0: * You can find further help on the libcurl development mailing list: michael@0: * http://cool.haxx.se/mailman/listinfo/curl-library/ michael@0: * michael@0: * NOTE 2 michael@0: * ------ michael@0: * michael@0: * Some of the following compile time checks are based on the fact michael@0: * that the dimension of a constant array can not be a negative one. michael@0: * In this way if the compile time verification fails, the compilation michael@0: * will fail issuing an error. The error description wording is compiler michael@0: * dependent but it will be quite similar to one of the following: michael@0: * michael@0: * "negative subscript or subscript is too large" michael@0: * "array must have at least one element" michael@0: * "-1 is an illegal array size" michael@0: * "size of array is negative" michael@0: * michael@0: * If you are building an application which tries to use an already michael@0: * built libcurl library and you are getting this kind of errors on michael@0: * this file, it is a clear indication that there is a mismatch between michael@0: * how the library was built and how you are trying to use it for your michael@0: * application. Your already compiled or binary library provider is the michael@0: * only one who can give you the details you need to properly use it. michael@0: */ michael@0: michael@0: /* michael@0: * Verify that some macros are actually defined. michael@0: */ michael@0: michael@0: #ifndef CURL_SIZEOF_LONG michael@0: # error "CURL_SIZEOF_LONG definition is missing!" michael@0: Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_TYPEOF_CURL_SOCKLEN_T michael@0: # error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!" michael@0: Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_SIZEOF_CURL_SOCKLEN_T michael@0: # error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!" michael@0: Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_TYPEOF_CURL_OFF_T michael@0: # error "CURL_TYPEOF_CURL_OFF_T definition is missing!" michael@0: Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_FORMAT_CURL_OFF_T michael@0: # error "CURL_FORMAT_CURL_OFF_T definition is missing!" michael@0: Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_FORMAT_CURL_OFF_TU michael@0: # error "CURL_FORMAT_CURL_OFF_TU definition is missing!" michael@0: Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_FORMAT_OFF_T michael@0: # error "CURL_FORMAT_OFF_T definition is missing!" michael@0: Error Compilation_aborted_CURL_FORMAT_OFF_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_SIZEOF_CURL_OFF_T michael@0: # error "CURL_SIZEOF_CURL_OFF_T definition is missing!" michael@0: Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_SUFFIX_CURL_OFF_T michael@0: # error "CURL_SUFFIX_CURL_OFF_T definition is missing!" michael@0: Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing michael@0: #endif michael@0: michael@0: #ifndef CURL_SUFFIX_CURL_OFF_TU michael@0: # error "CURL_SUFFIX_CURL_OFF_TU definition is missing!" michael@0: Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing michael@0: #endif michael@0: michael@0: /* michael@0: * Macros private to this header file. michael@0: */ michael@0: michael@0: #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1 michael@0: michael@0: #define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 michael@0: michael@0: /* michael@0: * Verify that the size previously defined and expected for long michael@0: * is the same as the one reported by sizeof() at compile time. michael@0: */ michael@0: michael@0: typedef char michael@0: __curl_rule_01__ michael@0: [CurlchkszEQ(long, CURL_SIZEOF_LONG)]; michael@0: michael@0: /* michael@0: * Verify that the size previously defined and expected for michael@0: * curl_off_t is actually the the same as the one reported michael@0: * by sizeof() at compile time. michael@0: */ michael@0: michael@0: typedef char michael@0: __curl_rule_02__ michael@0: [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)]; michael@0: michael@0: /* michael@0: * Verify at compile time that the size of curl_off_t as reported michael@0: * by sizeof() is greater or equal than the one reported for long michael@0: * for the current compilation. michael@0: */ michael@0: michael@0: typedef char michael@0: __curl_rule_03__ michael@0: [CurlchkszGE(curl_off_t, long)]; michael@0: michael@0: /* michael@0: * Verify that the size previously defined and expected for michael@0: * curl_socklen_t is actually the the same as the one reported michael@0: * by sizeof() at compile time. michael@0: */ michael@0: michael@0: typedef char michael@0: __curl_rule_04__ michael@0: [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)]; michael@0: michael@0: /* michael@0: * Verify at compile time that the size of curl_socklen_t as reported michael@0: * by sizeof() is greater or equal than the one reported for int for michael@0: * the current compilation. michael@0: */ michael@0: michael@0: typedef char michael@0: __curl_rule_05__ michael@0: [CurlchkszGE(curl_socklen_t, int)]; michael@0: michael@0: /* ================================================================ */ michael@0: /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ michael@0: /* ================================================================ */ michael@0: michael@0: /* michael@0: * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow michael@0: * these to be visible and exported by the external libcurl interface API, michael@0: * while also making them visible to the library internals, simply including michael@0: * setup.h, without actually needing to include curl.h internally. michael@0: * If some day this section would grow big enough, all this should be moved michael@0: * to its own header file. michael@0: */ michael@0: michael@0: /* michael@0: * Figure out if we can use the ## preprocessor operator, which is supported michael@0: * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__ michael@0: * or __cplusplus so we need to carefully check for them too. michael@0: */ michael@0: michael@0: #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \ michael@0: defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \ michael@0: defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \ michael@0: defined(__ILEC400__) michael@0: /* This compiler is believed to have an ISO compatible preprocessor */ michael@0: #define CURL_ISOCPP michael@0: #else michael@0: /* This compiler is believed NOT to have an ISO compatible preprocessor */ michael@0: #undef CURL_ISOCPP michael@0: #endif michael@0: michael@0: /* michael@0: * Macros for minimum-width signed and unsigned curl_off_t integer constants. michael@0: */ michael@0: michael@0: #ifdef CURL_ISOCPP michael@0: # define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val ## Suffix michael@0: #else michael@0: # define __CURL_OFF_T_C_HELPER2(Val,Suffix) Val/**/Suffix michael@0: #endif michael@0: #define __CURL_OFF_T_C_HELPER1(Val,Suffix) __CURL_OFF_T_C_HELPER2(Val,Suffix) michael@0: #define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_T) michael@0: #define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HELPER1(Val,CURL_SUFFIX_CURL_OFF_TU) michael@0: michael@0: /* michael@0: * Get rid of macros private to this header file. michael@0: */ michael@0: michael@0: #undef CurlchkszEQ michael@0: #undef CurlchkszGE michael@0: michael@0: /* michael@0: * Get rid of macros not intended to exist beyond this point. michael@0: */ michael@0: michael@0: #undef CURL_PULL_WS2TCPIP_H michael@0: #undef CURL_PULL_SYS_TYPES_H michael@0: #undef CURL_PULL_SYS_SOCKET_H michael@0: #undef CURL_PULL_STDINT_H michael@0: #undef CURL_PULL_INTTYPES_H michael@0: michael@0: #undef CURL_TYPEOF_CURL_SOCKLEN_T michael@0: #undef CURL_TYPEOF_CURL_OFF_T michael@0: michael@0: #endif /* __CURL_CURLRULES_H */