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