-
Notifications
You must be signed in to change notification settings - Fork 0
/
preprocessor_complement.h
50 lines (39 loc) · 1.4 KB
/
preprocessor_complement.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
/*
* CREATED BY SHPEGUN60
*
* COMPLEMENT FIND MACROCES
*/
#ifndef __PREPROCESSOR_COMPLEMENT_H__
#define __PREPROCESSOR_COMPLEMENT_H__ 1
#ifdef __cplusplus
extern "C" {
#endif
/* -- Definitions -- */
#define PREPROCESSOR_COMPL_IMPL_0 1
#define PREPROCESSOR_COMPL_IMPL_1 0
/* -- Macros -- */
/*****************************************************************************************************************************
* Complementry digit find
*
* PREPROCESSOR_COMPL(0) // expand to 1
* PREPROCESSOR_COMPL(1) // expand to 0
* PREPROCESSOR_COMPL(aaa) // expand to PREPROCESSOR_COMPL_IMPL_aaa ->is not work!!! need: PREPROCESSOR_COMPL(PREPROCESSOR_BOOL(aaa)) --> expands to 0
*
*/
#if defined(_MSC_VER) && !defined(__clang__)
#define PREPROCESSOR_COMPL_IMPL_EXPAND(x) x
#define PREPROCESSOR_COMPL_IMPL(x) PREPROCESSOR_COMPL_IMPL_EXPAND(PREPROCESSOR_COMPL_IMPL_##x)
#else
#define PREPROCESSOR_COMPL_IMPL(x) PREPROCESSOR_COMPL_IMPL_##x
#endif
#if defined(__MWERKS__)
#define PREPROCESSOR_COMPL_TOKEN(x) PREPROCESSOR_COMPL_IMPL##x
#define PREPROCESSOR_COMPL(x) PREPROCESSOR_COMPL_TOKEN((x))
#else
#define PREPROCESSOR_COMPL(x) PREPROCESSOR_COMPL_IMPL(x) // expand x
#endif
/*****************************************************************************************************************************/
#ifdef __cplusplus
}
#endif
#endif /* __PREPROCESSOR_COMPLEMENT_H__ */