src/macros.h

changeset 125
85814c0918c5
parent 119
bdf8d46c145f
child 129
54f27fa8f32f
equal deleted inserted replaced
124:a7b769a0e537 125:85814c0918c5
24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #pragma once 29 #ifndef BOTC_MACROS_H
30 #define BOTC_MACROS_H
30 31
31 #if !defined (__cplusplus) || __cplusplus < 201103L 32 #if !defined (__cplusplus) || __cplusplus < 201103L
32 # error botc requires a C++11-compliant compiler to be built 33 # error botc requires a C++11-compliant compiler to be built
33 #endif 34 #endif
34 35
41 #define MAKE_VERSION_NUMBER(MAJ, MIN, PAT) ((MAJ * 10000) + (MIN * 100) + PAT) 42 #define MAKE_VERSION_NUMBER(MAJ, MIN, PAT) ((MAJ * 10000) + (MIN * 100) + PAT)
42 #define VERSION_NUMBER MAKE_VERSION_NUMBER (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) 43 #define VERSION_NUMBER MAKE_VERSION_NUMBER (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
43 44
44 // On Windows, files are case-insensitive 45 // On Windows, files are case-insensitive
45 #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__) 46 #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
46 #define FILE_CASEINSENSITIVE 47 # define FILE_CASEINSENSITIVE
47 #endif 48 #endif
48 49
49 #define named_enum enum 50 #define named_enum enum
50 #define elif else if 51 #define elif else if
51 #define types public 52 #define types public
54 #ifndef __GNUC__ 55 #ifndef __GNUC__
55 # define __attribute__(X) 56 # define __attribute__(X)
56 #endif 57 #endif
57 58
58 #define deprecated __attribute__ ((deprecated)) 59 #define deprecated __attribute__ ((deprecated))
60
61 template<typename... argtypes>
62 void error (const char* fmtstr, const argtypes&... args);
63
64 #define BOTC_GENERIC_ASSERT(A,B,OP,COMPLAINT) ((A OP B) ? (void) 0 : \
65 error ("assertion failed at " __FILE__ ":%1: " #A " (%2) " COMPLAINT " " #B " (%3)", __LINE__, A, B));
66
67 #define ASSERT_EQ(A,B) BOTC_GENERIC_ASSERT (A, B, ==, "does not equal")
68 #define ASSERT_NE(A,B) BOTC_GENERIC_ASSERT (A, B, !=, "is no different from")
69 #define ASSERT_LT(A,B) BOTC_GENERIC_ASSERT (A, B, <, "is not less than")
70 #define ASSERT_GT(A,B) BOTC_GENERIC_ASSERT (A, B, >, "is not greater than")
71 #define ASSERT_LT_EQ(A,B) BOTC_GENERIC_ASSERT (A, B, <=, "is not at most")
72 #define ASSERT_GT_EQ(A,B) BOTC_GENERIC_ASSERT (A, B, >=, "is not at least")
73 #define ASSERT_RANGE(A,MIN,MAX) { ASSERT_LT_EQ(A, MAX); ASSERT_GT_EQ(A, MIN); }
74 #define ASSERT(A) ASSERT_EQ (A, true)
75
76 #endif // BOTC_MACROS_H

mercurial