sources/basics.h

branch
protocol5
changeset 131
4996c8684b93
parent 114
0e7f3ecdf65a
child 157
42bb29924218
equal deleted inserted replaced
130:9f54db6f9922 131:4996c8684b93
1 /* 1 /*
2 Copyright 2014, 2015 Teemu Piippo 2 Copyright 2014 - 2016 Teemu Piippo
3 All rights reserved. 3 All rights reserved.
4 4
5 Redistribution and use in source and binary forms, with or without 5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions 6 modification, are permitted provided that the following conditions
7 are met: 7 are met:
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #pragma once 31 #pragma once
32 #include <stdlib.h>
33
32 #if !defined(_MSC_VER) && !defined(__cdecl) 34 #if !defined(_MSC_VER) && !defined(__cdecl)
33 # define __cdecl 35 # define __cdecl
34 #endif 36 #endif
35 37
36 #define MACRO_TO_STRING_2(A) #A 38 #define MACRO_TO_STRING_2(A) #A
86 T clamp (T a, T b, T c) 88 T clamp (T a, T b, T c)
87 { 89 {
88 return (a < b) ? b : (a > c) ? c : a; 90 return (a < b) ? b : (a > c) ? c : a;
89 } 91 }
90 92
93 template <typename T, size_t N>
94 char (&_ArraySizeHelper(T (&array)[N]))[N];
95 #define countof(array) (sizeof(_ArraySizeHelper( array )))
96
91 struct Exitception {}; 97 struct Exitception {};
92 98
93 END_ZFC_NAMESPACE 99 END_ZFC_NAMESPACE

mercurial