1 #ifndef __CARES_RULES_H
2 #define __CARES_RULES_H
5 /* Copyright (C) 2009 by Daniel Stenberg et al
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.
18 /* ================================================================ */
19 /* COMPILE TIME SANITY CHECKS */
20 /* ================================================================ */
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.
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.
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.
39 * Do not deactivate any check, these are done to make sure that the
40 * library is properly built and used.
42 * You can find further help on the c-ares development mailing list:
43 * http://cool.haxx.se/mailman/listinfo/c-ares/
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:
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"
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.
68 * Verify that some macros are actually defined.
71 #ifndef CARES_SIZEOF_LONG
72 # error "CARES_SIZEOF_LONG definition is missing!"
73 Error Compilation_aborted_CARES_SIZEOF_LONG_is_missing
76 #ifndef CARES_TYPEOF_ARES_SOCKLEN_T
77 # error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!"
78 Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing
81 #ifndef CARES_SIZEOF_ARES_SOCKLEN_T
82 # error "CARES_SIZEOF_ARES_SOCKLEN_T definition is missing!"
83 Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_is_missing
87 * Macros private to this header file.
90 #define CareschkszEQ(t, s) sizeof(t) == s ? 1 : -1
92 #define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
95 * Verify that the size previously defined and expected for long
96 * is the same as the one reported by sizeof() at compile time.
101 [CareschkszEQ(long, CARES_SIZEOF_LONG)];
104 * Verify that the size previously defined and expected for
105 * ares_socklen_t is actually the the same as the one reported
106 * by sizeof() at compile time.
111 [CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)];
114 * Verify at compile time that the size of ares_socklen_t as reported
115 * by sizeof() is greater or equal than the one reported for int for
116 * the current compilation.
121 [CareschkszGE(ares_socklen_t, int)];
123 /* ================================================================ */
124 /* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
125 /* ================================================================ */
128 * Get rid of macros private to this header file.
135 * Get rid of macros not intended to exist beyond this point.
138 #undef CARES_PULL_WS2TCPIP_H
139 #undef CARES_PULL_SYS_TYPES_H
140 #undef CARES_PULL_SYS_SOCKET_H
142 #undef CARES_TYPEOF_ARES_SOCKLEN_T
144 #endif /* __CARES_RULES_H */