Itasca C++ Interface
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
basedef.h
Go to the documentation of this file.
1 #pragma once
2 
12 #include "export.h"
13 #include <wchar.h>
14 
18 #if defined(BASE_LIB) | defined(BASE2017_LIB)
19 # define BASE_EXPORT EXPORT_TAG
20 #else
21 # define BASE_EXPORT IMPORT_TAG
22 #endif
23 //#define itascaxd "Error: Need to define DIM and include dim.h"
24 
25 typedef wchar_t Char;
26 typedef char Byte;
27 typedef unsigned char UByte;
28 typedef short Short;
29 typedef unsigned short UShort;
30 typedef int Int;
31 typedef unsigned int UInt;
32 #ifdef __LINUX
33 typedef long long Long;
34 typedef unsigned long long ULong;
35 #else
36 typedef __int64 Long;
37 typedef unsigned __int64 ULong;
38 #endif
39 typedef float Float;
40 typedef double Double;
41 typedef unsigned int TType;
42 
43 // Better typedefs to use in the future
44 using char16 = char16_t; // Assume UTF-16 encoding
45 using char8 = char; // Assuming UTF-8 encoding
46 using int8 = signed char;
47 using uint8 = unsigned char;
48 using int16 = short;
49 using uint16 = unsigned short;
50 using int32 = int;
51 using uint32 = unsigned int;
52 using int64 = Long;
53 using uint64 = ULong;
54 
55 #ifdef __LINUX
56 #include <fenv.h>
57 #define _EM_OVERFLOW FE_OVERFLOW
58 #define _EM_INVALID FE_INVALID
59 #define _EM_UNDERFLOW FE_UNDERFLOW
60 #define _EM_ZERODIVIDE FE_DIVBYZERO
61 inline unsigned doClearFP() {
62  int ret = fetestexcept(FE_ALL_EXCEPT);
63  feclearexcept(FE_ALL_EXCEPT);
64  return (unsigned)ret;
65 }
66 #define _clearfp doClearFP
67 #define __noop() { }
68 #define OS_CURRENT 2
69 #else
70 #define OS_CURRENT 1
71 #endif
72 
73 #define OS_LINUX 2
74 #define OS_WINDOWS 1
75 
76 #ifndef DOXYGEN
77 # ifdef _DEBUG
78 # define CHECK_FP_STATUS checkFPStatus(__FILE__,__LINE__)
79 # define CLEAR_FP_STATUS _clearfp()
80 # else
81 # define CHECK_FP_STATUS __noop()
82 # define CLEAR_FP_STATUS __noop()
83 # endif
84 // A concise version of CHECK_FP_STATUS.
85 # define FP_S CHECK_FP_STATUS
86 // A concise version of CLEAR_FP_STATUS.
87 # define FP_C CLEAR_FP_STATUS
88 
89 // To check overflow error or invalid floating point result from the \a line of the \a file
90 BASE_EXPORT const char16 *checkFPStatus(const char *file=0,UInt line=0);
91 enum FloatingPointCheck { FloatingPointCheckOff, FloatingPointCheckWarning, FloatingPointCheckException };
92 BASE_EXPORT FloatingPointCheck floatingPointCheckStatus();
93 BASE_EXPORT void floatingPointCheckStatus(FloatingPointCheck fpc);
94 BASE_EXPORT bool isCurrentOS(int i);
95 #endif
96 
97 #define FOR(x,y) for (auto x=(y).begin();x!=(y).end();++x)
98 
100 #ifdef NDEBUG
101 static constexpr bool isDebugCompile = false;
102 #else
103 static constexpr bool isDebugCompile = true;
104 #endif
105 // EoF
char Byte
signed 8 bit
Definition: basedef.h:26
unsigned short UShort
unsigned 16 bit
Definition: basedef.h:29
unsigned __int64 ULong
unsigned 64 bit
Definition: basedef.h:37
Defines automatic generation of DLL exports and imports for each system supported.
wchar_t Char
string character type, Unicode supporting.
Definition: basedef.h:25
int Int
signed 32 bit
Definition: basedef.h:30
unsigned int UInt
unsigned 32 bit
Definition: basedef.h:31
__int64 Long
signed 64 bit
Definition: basedef.h:36
unsigned int TType
class type indicator
Definition: basedef.h:41
#define BASE_EXPORT
Definition: basedef.h:21
double Double
64 bit floating point
Definition: basedef.h:40
unsigned char UByte
unsigned 8 bit
Definition: basedef.h:27
short Short
signed 16 bit
Definition: basedef.h:28
float Float
32 bit floating point
Definition: basedef.h:39