-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreprocessor_nat_op.h
67 lines (54 loc) · 2.5 KB
/
preprocessor_nat_op.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* CREATED BY SHPEGUN60
*
* DIGIT comparation macroces
*/
#ifndef __PREPROCESSOR_NAT_OP_H__
#define __PREPROCESSOR_NAT_OP_H__ 1
/*********************************************************************************************************************
* DIGITS EQUALUATION MACRO
*
* PREPROCESSOR_SIMPLE_EQUAL(10, 10) // expands to 1
* PREPROCESSOR_SIMPLE_EQUAL(10, 11) // expands to 0
* PREPROCESSOR_SIMPLE_EQUAL('c', 'c') // expands to 1
*/
#define PREPROCESSOR_SIMPLE_EQUAL(a, b) PREPROCESSOR_SIMPLE_EQUAL_IMPL(a, b)
#define PREPROCESSOR_SIMPLE_EQUAL_IMPL(a, b) ((a) == (b))
/*********************************************************************************************************************
* DIGITS MORE COMPARATION MACRO
*
* PREPROCESSOR_MORE_THAN(10, 1) // expands to 1
* PREPROCESSOR_MORE_THAN(10, 11) // expands to 0
* PREPROCESSOR_MORE_THAN('c', 'c') // expands to 0
*/
//>
#define PREPROCESSOR_MORE_THAN(a, b) PREPROCESSOR_MORE_THAN_IMPL(a, b)
#define PREPROCESSOR_MORE_THAN_IMPL(a, b) ((a) > (b))
//>=
#define PREPROCESSOR_MORE_OR_EQ_THAN(a, b) PREPROCESSOR_MORE_OR_EQ_THAN_IMPL(a, b)
#define PREPROCESSOR_MORE_OR_EQ_THAN_IMPL(a, b) ((a) >= (b))
/*********************************************************************************************************************
* DIGITS LESS COMPARATION MACRO
*
* PREPROCESSOR_LESS_THAN(10, 1) // expands to 0
* PREPROCESSOR_LESS_THAN(10, 11) // expands to 1
* PREPROCESSOR_LESS_THAN('c', 'c') // expands to 0
*/
//<
#define PREPROCESSOR_LESS_THAN(a, b) PREPROCESSOR_LESS_THAN_IMPL(a, b)
#define PREPROCESSOR_LESS_THAN_IMPL(a, b) ((a) < (b))
//<=
#define PREPROCESSOR_LESS_OR_EQ_THAN(a, b) PREPROCESSOR_LESS_OR_EQ_THAN_IMPL(a, b)
#define PREPROCESSOR_LESS_OR_EQ_THAN_IMPL(a, b) ((a) <= (b))
/*********************************************************************************************************************
* DIGITS MAX FINDER MACRO
*
* PREPROCESSOR_MAX(10, 1) // expands to 10
* PREPROCESSOR_MAX(10, 11) // expands to 11
* PREPROCESSOR_MAX('c', 'c') // expands to 'c'
*/
#define PREPROCESSOR_MAX(a, b) PREPROCESSOR_MAX_IMPL(a, b)
#define PREPROCESSOR_MAX_IMPL(a, b) (PREPROCESSOR_MORE_THAN(a, b) ? (a) : (b))
#define PREPROCESSOR_MIN(a, b) PREPROCESSOR_MIN_IMPL(a, b)
#define PREPROCESSOR_MIN_IMPL(a, b) (PREPROCESSOR_LESS_THAN(a, b) ? (a) : (b))
#endif /* __PREPROCESSOR_NAT_OP_H__ */