1 #ifndef __CARES_RULES_H 2 #define __CARES_RULES_H 3 4 5 /* Copyright (C) 2009 - 2021 by Daniel Stenberg et al 6 * 7 * Permission to use, copy, modify, and distribute this software and its 8 * documentation for any purpose and without fee is hereby granted, provided 9 * that the above copyright notice appear in all copies and that both that 10 * copyright notice and this permission notice appear in supporting 11 * documentation, and that the name of M.I.T. not be used in advertising or 12 * publicity pertaining to distribution of the software without specific, 13 * written prior permission. M.I.T. makes no representations about the 14 * suitability of this software for any purpose. It is provided "as is" 15 * without express or implied warranty. 16 */ 17 18 /* ================================================================ */ 19 /* COMPILE TIME SANITY CHECKS */ 20 /* ================================================================ */ 21 22 /* 23 * NOTE 1: 24 * ------- 25 * 26 * All checks done in this file are intentionally placed in a public 27 * header file which is pulled by ares.h when an application is 28 * being built using an already built c-ares library. Additionally 29 * this file is also included and used when building the library. 30 * 31 * If compilation fails on this file it is certainly sure that the 32 * problem is elsewhere. It could be a problem in the ares_build.h 33 * header file, or simply that you are using different compilation 34 * settings than those used to build the library. 35 * 36 * Nothing in this file is intended to be modified or adjusted by the 37 * c-ares library user nor by the c-ares library builder. 38 * 39 * Do not deactivate any check, these are done to make sure that the 40 * library is properly built and used. 41 * 42 * You can find further help on the c-ares development mailing list: 43 * http://lists.haxx.se/listinfo/c-ares/ 44 * 45 * NOTE 2 46 * ------ 47 * 48 * Some of the following compile time checks are based on the fact 49 * that the dimension of a constant array can not be a negative one. 50 * In this way if the compile time verification fails, the compilation 51 * will fail issuing an error. The error description wording is compiler 52 * dependent but it will be quite similar to one of the following: 53 * 54 * "negative subscript or subscript is too large" 55 * "array must have at least one element" 56 * "-1 is an illegal array size" 57 * "size of array is negative" 58 * 59 * If you are building an application which tries to use an already 60 * built c-ares library and you are getting this kind of errors on 61 * this file, it is a clear indication that there is a mismatch between 62 * how the library was built and how you are trying to use it for your 63 * application. Your already compiled or binary library provider is the 64 * only one who can give you the details you need to properly use it. 65 */ 66 67 /* 68 * Verify that some macros are actually defined. 69 */ 70 71 #ifndef CARES_TYPEOF_ARES_SOCKLEN_T 72 # error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!" 73 Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing 74 #endif 75 76 /* 77 * Macros private to this header file. 78 */ 79 80 #define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1 81 82 #define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1 83 84 /* 85 * Verify that the size previously defined and expected for 86 * ares_socklen_t is actually the same as the one reported 87 * by sizeof() at compile time. 88 */ 89 90 typedef char 91 __cares_rule_02__ 92 [CareschkszEQ(ares_socklen_t, sizeof(CARES_TYPEOF_ARES_SOCKLEN_T))]; 93 94 /* 95 * Verify at compile time that the size of ares_socklen_t as reported 96 * by sizeof() is greater or equal than the one reported for int for 97 * the current compilation. 98 */ 99 100 typedef char 101 __cares_rule_03__ 102 [CareschkszGE(ares_socklen_t, int)]; 103 104 /* ================================================================ */ 105 /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */ 106 /* ================================================================ */ 107 108 /* 109 * Get rid of macros private to this header file. 110 */ 111 112 #undef CareschkszEQ 113 #undef CareschkszGE 114 115 /* 116 * Get rid of macros not intended to exist beyond this point. 117 */ 118 119 #undef CARES_PULL_WS2TCPIP_H 120 #undef CARES_PULL_SYS_TYPES_H 121 #undef CARES_PULL_SYS_SOCKET_H 122 123 #undef CARES_TYPEOF_ARES_SOCKLEN_T 124 125 #endif /* __CARES_RULES_H */ 126