LayOut C API
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
common.h
Go to the documentation of this file.
1 // Copyright 2015-2024 Trimble Inc. All rights reserved.
2 // This file is intended for public distribution.
3 
8 #ifndef SKETCHUP_COMMON_H_
9 #define SKETCHUP_COMMON_H_
10 
15 enum SUResult {
17 
19 
21 
22 
24 
26 
27 
29 
30 
31 
33 
35 
36 
38 
39 
41 
42 
43 
45 
46 
48 
50 
52 
53 
55 
57 
59 
60 
61 
63 
65 
67 
69 };
70 
71 // Define a platform-independent UTF16 type.
72 #if defined(__APPLE__) || defined(__LINUX__)
73  #ifndef FOUNDATION_IMPORT
74 typedef unsigned short unichar;
75  #endif // FOUNDATION_IMPORT
76 #else // WIN32
77  #include <wtypes.h>
78 typedef wchar_t unichar;
79 #endif
80 
81 #ifndef DOXYGEN_SHOULD_SKIP_THIS
82 
83  #define SU_EXPORT
84  #if defined WIN32 && !defined GSLAPI_NO_EXPORTS
85  #undef SU_EXPORT
86  #ifdef GSLAPI_API_EXPORTS
87  #define SU_EXPORT __declspec(dllexport)
88  #else
89  #define SU_EXPORT __declspec(dllimport)
90  #endif // GSLAPI_API_EXPORTS
91  #endif // WINDOWS
92 
93  #if defined __APPLE__ && !defined GSLAPI_NO_EXPORTS
94  #undef SU_EXPORT
95  #define SU_EXPORT __attribute__((visibility("default")))
96  #endif // #if defined __APPLE__
97 
98  #define DEFINE_SU_TYPE(TYPENAME) \
99  typedef struct { \
100  void* ptr; \
101  } TYPENAME;
102 
103 #endif // DOXYGEN_SHOULD_SKIP_THIS
104 
108 #define SU_RESULT SU_EXPORT enum SUResult
109 
114 #define SU_INVALID \
115  { 0 }
116 
121 #define SUIsValid(VARIABLE) ((VARIABLE).ptr != 0)
122 
127 #define SUIsInvalid(VARIABLE) ((VARIABLE).ptr == 0)
128 
132 #define SUSetInvalid(VARIABLE) (VARIABLE).ptr = 0
133 
137 #define SUAreEqual(VARIABLE1, VARIABLE2) ((VARIABLE1).ptr == (VARIABLE2).ptr)
138 
139 #include <stddef.h> // for size_t
140 
141 #if !defined(__STDC_HOSTED__) || (__STDC_HOSTED__ == 0)
142  // The host compiler does not implement C99
143  #ifdef WIN32
144 typedef __int64 int64_t;
145 typedef __int32 int32_t;
146 typedef __int16 int16_t;
147 typedef unsigned __int32 uint32_t;
148  #else
149  #error Unsupported compiler!
150  #endif
151 #else
152  #include <stdint.h>
153 #endif // #if !defined(__STDC_HOSTED__) || (__STDC_HOSTED__ == 0)
154 
155 #ifndef __cplusplus
156  // C compilers need this header for the bool type.
157  // This header maps bool to C99's _Bool type.
158  #include <stdbool.h>
159 #endif
160 
166 #ifndef SU_SUPPRESS_DEPRECATION_WARNINGS
167  #ifdef WIN32
168  #define SU_DEPRECATED_FUNCTION(version_num) \
169  __declspec(deprecated("first deprecated in " version_num))
170  #else
171  #define SU_DEPRECATED_FUNCTION(version_num) \
172  __attribute__((deprecated("first deprecated in " version_num)))
173  #endif
174 #else
175  #define SU_DEPRECATED_FUNCTION(version_num)
176 #endif
177 
178 #endif // SKETCHUP_COMMON_H_