Guardtime KSI c SDK
common.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013-2015 Guardtime, Inc.
3  *
4  * This file is part of the Guardtime client SDK.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License").
7  * You may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * http://www.apache.org/licenses/LICENSE-2.0
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES, CONDITIONS, OR OTHER LICENSES OF ANY KIND, either
13  * express or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  * "Guardtime" and "KSI" are trademarks or registered trademarks of
16  * Guardtime, Inc., and no license to trademarks is granted; Guardtime
17  * reserves and retains all trademark rights.
18  */
19 
20 #ifndef COMMON_H_
21 #define COMMON_H_
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #ifndef __GNUC__
28 # define KSI_ATTRIBUTE(x)
29 #else
30 # define KSI_ATTRIBUTE(x) __attribute__(x)
31 #endif
32 
33 
39 #define KSI_IS_VALID_TREE_LEVEL(level) (((level) <= 0xff) && ((int)(level) >= 0))
40 
44 #ifndef __KSI_NO_DEPRECATE__
45 # if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
46 # define KSI_FN_DEPRECATED(decl, comment) decl __attribute__((deprecated))
47 # elif defined(_WIN32)
48 # define KSI_FN_DEPRECATED(decl, comment) __declspec(deprecated) decl
49 # else
50 # define KSI_FN_DEPRECATED(decl, comment) decl
51 # endif
52 #else
53 # define KSI_FN_DEPRECATED(decl, comment) decl;
54 #endif
55 
59 #ifndef __KSI_NO_DEPRECATE__
60 # if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
61 # define KSI_VAR_DEPRECATED(decl, comment) decl __attribute__((deprecated))
62 # else
63  /* No reasonable way to show the warning with VS. */
64 # define KSI_VAR_DEPRECATED(decl, comment) decl
65 # endif
66 #else
67 # define KSI_VAR_DEPRECATED(decl, comment) decl
68 #endif
69 
73 #ifndef __KSI_NO_DEPRECATE__
74 # if defined(__GNUC__) && (__GNUC__ >= 6)
75 # define KSI_ENUM_DEPRECATED(decl, comment) decl __attribute__((deprecated))
76 # else
77  /* No reasonable way to show the warning with VS. */
78 # define KSI_ENUM_DEPRECATED(decl, comment) decl
79 # endif
80 #else
81 # define KSI_ENUM_DEPRECATED(decl, comment) decl
82 #endif
83 
84 #if defined(_WIN32) && defined(DLL_BUILD) && !(KSI_BUILD)
85 # define KSI_DEFINE_EXTERN(e) __declspec( dllimport ) extern e
86 #else
87 # define KSI_DEFINE_EXTERN(e) extern e
88 #endif
89 
93 #define KSI_UNUSED(x) KSI_ATTRIBUTE((__unused__)) x
94 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* COMMON_H_ */