1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12/** \file fbxarch.h
13 * Architecture definition.
14 *
15 * List of available preprocessor defines that can appear on various systems:
16 *
17 * Operating System Environment:
18 * FBXSDK_ENV_WIN (Windows)
19 * FBXSDK_ENV_WINSTORE (Windows Store App)
20 * FBXSDK_ENV_MAC (MacOSX)
21 * FBXSDK_ENV_IOS (iOS)
22 * FBXSDK_ENV_LINUX (Linux)
23 *
24 * Architecture:
25 * FBXSDK_ARCH_IX86 (Intel x86)
26 * FBXSDK_ARCH_AMD64 (AMD64)
27 * FBXSDK_ARCH_ARM (Advanced RISC Machine)
28 *
29 * Processor:
30 * FBXSDK_CPU_32 (32bit processor)
31 * FBXSDK_CPU_64 (64bit processor)
32 *
33 * Compiler:
34 * FBXSDK_COMPILER_MSC (Microsoft Compiler)
35 * FBXSDK_COMPILER_GNU (GNU Compiler)
36 * FBXSDK_COMPILER_INTEL (Intel Compiler)
37 * FBXSDK_COMPILER_CLANG (Clang Compiler)
38 *
39 * These definitions are based on the information found here:
40 * http://predef.sourceforge.net/index.php
41 *
42 */
43#ifndef _FBXSDK_CORE_ARCH_ARCH_H_
44#define _FBXSDK_CORE_ARCH_ARCH_H_
45
46#if defined(_WIN32) || defined(_WIN64) //Microsoft Windows ------------------------------
47
48 #define FBXSDK_ENV_WIN 1
49
50 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
51 #define FBXSDK_ENV_WINSTORE 1
52 #endif
53
54 #if defined(_M_X64)
55 #define FBXSDK_ARCH_AMD64 1
56 #define FBXSDK_CPU_64 1
57 #elif defined(_M_IX86)
58 #define FBXSDK_ARCH_IX86 1
59 #define FBXSDK_CPU_32 1
60 #elif defined(_M_ARM)
61 #define FBXSDK_ARCH_ARM 1
62 #define FBXSDK_CPU_32 1
63 #else
64 #error Unsupported architecture!
65 #endif
66
67 #if defined(_MSC_VER)
68 #define FBXSDK_COMPILER_MSC 1
69 #elif defined(__GNUC__)
70 #define FBXSDK_COMPILER_GNU 1
71 #elif defined(__ICL)
72 #define FBXSDK_COMPILER_INTEL 1
73 #else
74 #error Unsupported compiler!
75 #endif
76
77#elif defined(__APPLE__) || defined(__MACH__) //Apple MacOS/X ---------------------------
78
79 #include "TargetConditionals.h"
80
81 #define FBXSDK_ENV_MAC 1
82
83 #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
84 #define FBXSDK_ENV_IOS 1
85 #endif
86
87 #if defined(__i386__)
88 #define FBXSDK_ARCH_IX86 1
89 #define FBXSDK_CPU_32 1
90 #elif defined(__x86_64__) || defined(__x86_64)
91 #define FBXSDK_ARCH_AMD64 1
92 #define FBXSDK_CPU_64 1
93 #elif defined(__arm__)
94 #define FBXSDK_ARCH_ARM 1
95 #define FBXSDK_CPU_32 1
96 #elif defined(__arm64__)
97 #define FBXSDK_ARCH_ARM 1
98 #define FBXSDK_CPU_64 1
99 #else
100 #error Unsupported architecture!
101 #endif
102
103 #if defined(__GNUC__)
104 #define FBXSDK_COMPILER_GNU 1
105 #endif
106
107 #if defined(__clang__)
108 #define FBXSDK_COMPILER_CLANG 1
109 #endif
110
111 #if !defined(FBXSDK_COMPILER_GNU) && !defined(FBXSDK_COMPILER_CLANG)
112 #error Unsupported compiler!
113 #endif
114
115#elif defined(__linux__) || defined(__CYGWIN__) || defined(EMSCRIPTEN) || defined(ANDROID) //Linux ---------------------------------
116
117 #define FBXSDK_ENV_LINUX 1
118
119 #if defined(EMSCRIPTEN)
120 #define FBXSDK_ENV_EMSCRIPTEN 1
121 #endif
122
123 #if defined(ANDROID)
124 #define FBXSDK_ENV_ANDROID 1
125 #endif
126
127 #if defined(__i386__)
128 #define FBXSDK_ARCH_IX86 1
129 #define FBXSDK_CPU_32 1
130 #elif defined(__x86_64__) || defined(__x86_64)
131 #define FBXSDK_ARCH_AMD64 1
132 #define FBXSDK_CPU_64 1
133 #elif defined(__arm__)
134 #define FBXSDK_ARCH_ARM 1
135 #define FBXSDK_CPU_32 1
136 #elif defined(EMSCRIPTEN)
137 #define FBXSDK_ARCH_AMD64 1
138 #define FBXSDK_CPU_64 1
139 #else
140 #error Unsupported architecture!
141 #endif
142
143 #if defined(__GNUC__)
144 #define FBXSDK_COMPILER_GNU 1
145 #elif defined(EMSCRIPTEN)
146 #define FBXSDK_COMPILER_EMSCRIPTEN 1
147 #else
148 #error Unsupported compiler!
149 #endif
150 #else
151 #error Unsupported platform!
152#endif
153
154//---------------------------------------------------------------------------------------
155//Compiler Specifics
156#if defined(FBXSDK_SHARED)
157 #if defined(FBXSDK_COMPILER_MSC) || defined(FBXSDK_COMPILER_INTEL)
158 #define FBXSDK_DLLIMPORT __declspec(dllimport)
159 #define FBXSDK_DLLEXPORT __declspec(dllexport)
160 #elif defined(FBXSDK_COMPILER_GNU) && (__GNUC__ >= 4)
161 #define FBXSDK_DLLIMPORT __attribute__((visibility("default")))
162 #define FBXSDK_DLLEXPORT __attribute__((visibility("default")))
163 #else
164 #define FBXSDK_DLLIMPORT
165 #define FBXSDK_DLLEXPORT
166 #endif
167#else
168 #define FBXSDK_DLLIMPORT
169 #define FBXSDK_DLLEXPORT
170#endif
171
172#ifndef FBXSDK_DLL
173 #define FBXSDK_DLL FBXSDK_DLLIMPORT
174#endif
175
176#if defined(FBXSDK_COMPILER_MSC)
177 #pragma warning(disable : 4251) //'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
178 #if _MSC_VER >= 1300 // 7.1
179 #define FBX_DEPRECATED __declspec(deprecated)
180 #else
181 #define FBX_DEPRECATED
182 #endif
183#elif defined(FBXSDK_COMPILER_GNU) || defined(FBXSDK_COMPILER_EMSCRIPTEN)
184 #define FBX_DEPRECATED __attribute__((deprecated))
185#elif defined(FBXSDK_COMPILER_INTEL)
186 #if __INTEL_COMPILER >= 810
187 #define FBX_DEPRECATED __declspec(deprecated)
188 #else
189 #define FBX_DEPRECATED
190 #endif
191#else
192 #error Unsupported compiler!
193#endif
194
195#ifdef FBXSDK_COMPILER_CLANG
196 #define FBX_UNUSED(p) _Pragma(FBX_STRINGIFY(unused(p)))
197#else
198 #define FBX_UNUSED(p) (void)(p)
199#endif
200
201//---------------------------------------------------------------------------------------
202//Platform Standardization
203#ifndef NULL
204 #if defined(__GNUG__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
205 #define NULL (__null)
206 #else
207 #if defined(__cplusplus)
208 #define NULL 0
209 #else
210 #define NULL ((void*)0)
211 #endif
212 #endif
213#endif
214
215#if !defined(_MAX_PATH)
216 #define _MAX_PATH 260
217#endif
218
219#if defined(FBXSDK_ENV_WIN)
220 #define snprintf _snprintf //for stdio.h platform compatibility
221#endif
222
223#if !defined(FBXSDK_COMPILER_MSC)
224 #ifndef strcmpi
225 #define strcmpi strcasecmp
226 #endif
227 #ifndef stricmp
228 #define stricmp strcasecmp
229 #endif
230 #ifndef strncmpi
231 #define strncmpi strncasecmp
232 #endif
233 #ifndef strnicmp
234 #define strnicmp strncasecmp
235 #endif
236#endif
237
238#endif /* _FBXSDK_CORE_ARCH_ARCH_H_ */
239