-
Notifications
You must be signed in to change notification settings - Fork 2
/
OSCore.h
661 lines (561 loc) · 19.3 KB
/
OSCore.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
/***************************************************************************************************************:')
OSCore.h
Include the main Linux and Windows headers. Some Windows types ported to Linux.
Debug and error handling functions, macros and strings.
Fabrice Le Bars
Created : 2007
***************************************************************************************************************:)*/
// Prevent Visual Studio Intellisense from defining _WIN32 and _MSC_VER when we use
// Visual Studio to edit Linux or Borland C++ code.
#ifdef __linux__
# undef _WIN32
#endif // __linux__
#if defined(__GNUC__) || defined(__BORLANDC__)
# undef _MSC_VER
#endif // defined(__GNUC__) || defined(__BORLANDC__)
#ifndef OSCORE_H
#define OSCORE_H
/*
Predefined macros depending on the compiler :
_ Visual Studio : _MSC_VER
_ Borland C++ Builder : __BORLANDC__
_ GCC : __GNUC__
_ clang : __clang__
Predefined macros depending on the target operating system :
_ 32 bit Windows : _WIN32 & !_WIN64
_ 32 and 64 bit Windows : _WIN32
_ 64 bit Windows : _WIN32 & _WIN64
_ 32 bit Linux : __linux__ & !_LP64
_ 32 and 64 bit Linux : __linux__
_ 64 bit Linux : __linux__ & _LP64
_ Android : __ANDROID__
_ Mac OS : __APPLE__
_ Windows CE : WINCE
See also https://sourceforge.net/p/predef/wiki/Architectures/.
*/
#ifdef _WIN32
// Set the default target Windows version to at least Windows XP, unless we use
// Borland C++ Builder 5 for which it is set to Windows 2000.
# ifdef __BORLANDC__
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0500
# endif // !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
# else
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0501)
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif // !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0501)
# endif // __BORLANDC__
#endif // _WIN32
#ifdef _WIN32
#ifdef __GNUC__
#if defined(UNICODE) || defined(_UNICODE)
#ifndef UNICODE
#define UNICODE
#endif // !UNICODE
#ifndef _UNICODE
#define _UNICODE
#endif // !_UNICODE
#endif // defined(UNICODE) || defined(_UNICODE)
#endif // __GNUC__
#endif // _WIN32
#ifdef _MSC_VER
// Disable some Visual Studio warnings.
# ifndef CRT_SECURE_NO_DEPRECATE
# define CRT_SECURE_NO_DEPRECATE
# endif // CRT_SECURE_NO_DEPRECATE
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif // _CRT_SECURE_NO_WARNINGS
# ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
# define _WINSOCK_DEPRECATED_NO_WARNINGS
# endif // _WINSOCK_DEPRECATED_NO_WARNINGS
//# ifndef _CRT_NONSTDC_NO_WARNINGS
//# define _CRT_NONSTDC_NO_WARNINGS
//# endif // _CRT_NONSTDC_NO_WARNINGS
// To avoid compiler warnings about functions compiled as native code (if /clr).
# if defined(__cplusplus) && defined(_M_CEE)
# pragma warning(disable : 4793)
# endif // defined(__cplusplus) && defined(_M_CEE)
// Since probably Visual Studio 2012, it is forbidden to define inline even in C while it is only available in C++.
// _ALLOW_KEYWORD_MACROS allows to bypass this check (see xkeycheck.h).
// This should be changed if inline become a C keyword in future versions of Visual Studio.
# ifndef __cplusplus
# ifndef _ALLOW_KEYWORD_MACROS
# define _ALLOW_KEYWORD_MACROS
# endif // _ALLOW_KEYWORD_MACROS
# endif // __cplusplus
// Enable additional features in math.h.
# ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES
# endif // _USE_MATH_DEFINES
// Enable additional debug features for malloc functions.
# if defined(_DEBUG) && !defined(DISABLE_ADDITIONAL_DEBUG_FEATURES)
# ifndef _CRTDBG_MAP_ALLOC
# define _CRTDBG_MAP_ALLOC
# endif // _CRTDBG_MAP_ALLOC
# include <stdlib.h>
# ifndef WINCE
# include <crtdbg.h>
# endif // WINCE
# endif // defined(_DEBUG) && !defined(DISABLE_ADDITIONAL_DEBUG_FEATURES)
#endif // _MSC_VER
#ifdef __GNUC__
// Enable GNU extensions.
# ifndef _GNU_SOURCE
# define _GNU_SOURCE
# endif // _GNU_SOURCE
// Reentrant versions of several functions get declared in libc.
# ifndef _REENTRANT
# define _REENTRANT
# endif // _REENTRANT
// Thread-safe versions of several functions get declared in libc.
# ifndef _THREAD_SAFE
# define _THREAD_SAFE
# endif // _THREAD_SAFE
// To fix...
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
//#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
//#pragma GCC diagnostic push
//#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
//
//#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
//#pragma GCC diagnostic pop
//#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#endif // __GNUC__
#if defined(_MSC_VER) && defined(WINCE)
// Disable some Visual Studio warnings that appear for WINCE.
#pragma warning(disable : 4201)
#pragma warning(disable : 4214)
#pragma warning(disable : 4115)
#endif // defined(_MSC_VER) && defined(WINCE)
// C Standard Library headers.
#include <assert.h> // Diagnostics.
#include <ctype.h> // Character Class Tests.
#include <float.h> // Implementation-defined Floating-Point Limits.
#include <limits.h> // Implementation-defined Limits.
#include <locale.h> // Locale-specific Information.
#include <math.h> // Mathematical Functions.
#include <setjmp.h> // Non-local Jumps.
#include <stdarg.h> // Variable Argument Lists.
#include <stddef.h> // Definitions of General Use.
#include <stdio.h> // Input and Output.
#include <stdlib.h> // Utility functions.
#include <string.h> // String functions.
#include <time.h> // Time and Date functions.
#ifndef WINCE
#include <errno.h> // Error Codes Reported by (Some) Library Functions.
#include <signal.h> // Signals.
#endif // !WINCE
// C99 headers. Some headers are not supported by all the compilers or depend
// on its options.
#ifdef __GNUC__
// See https://stackoverflow.com/questions/3233054/error-int32-max-was-not-declared-in-this-scope
#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif // !__STDC_LIMIT_MACROS
//#include <complex.h> // Complex arithmetic.
//#include <fenv.h> // IEEE-style floating-point arithmetic.
//#include <inttypes.h> // Integer types.
//#include <iso646.h> // ISO 646 variant character sets.
//#include <stdbool.h> // Boolean type name and constants.
#include <stdint.h> // Integer types with size constraints.
//#include <tgmath.h> // Type-generic math functions.
//#include <wchar.h> // Wide streams and several kinds of strings.
//#include <wctype.h> // Wide characters.
#endif // __GNUC__
#if defined(_MSC_VER) && _MSC_VER >= 1600
#include <stdint.h>
#endif // defined(_MSC_VER) && _MSC_VER >= 1600
#ifndef WINCE
#include <fcntl.h>
#endif // !WINCE
#ifdef _WIN32
#include <tchar.h>
// Prevent Winsock.h from being included by the Windows.h header.
// This must be done if we plan to include Winsock2.h in other files.
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // !WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
#include <unistd.h>
#include <sys/time.h>
#endif // _WIN32
#if defined(_MSC_VER) && defined(WINCE)
// Restore the Visual Studio warnings previously disabled.
#pragma warning(default : 4115)
#pragma warning(default : 4214)
#pragma warning(default : 4201)
#endif // defined(_MSC_VER) && defined(WINCE)
#ifndef EXTERN_C
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C extern
#endif // __cplusplus
#endif // !EXTERN_C
#ifndef __cplusplus
#ifndef inline
#ifdef _MSC_VER
#define inline __inline
#endif // _MSC_VER
#ifdef __BORLANDC__
#define inline __inline
#endif // __BORLANDC__
#ifdef __GNUC__
// extern __inline__ in ws2tcpip.h for GNU?
#ifdef _WIN32
#if (__MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) || (defined (__clang__))
// Problem with the use of inline in _mingw.h for WS2TCPIP_INLINE...
#include <ws2tcpip.h>
#define inline static __inline__
#else
#define inline static __inline__
#endif // (__MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) || (defined (__clang__))
#else
#define inline static __inline__
#endif // _WIN32
#endif // __GNUC__
#endif // !inline
#endif // !__cplusplus
#ifndef _WIN32
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long LONG;
typedef unsigned long ULONG;
typedef float FLOAT;
#endif // !_WIN32
typedef double DOUBLE;
#ifdef __GNUC__
#undef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P) (void)(P)
#endif // __GNUC__
#ifdef __BORLANDC__
#undef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(P)
#endif // __BORLANDC__
// Taken from Visual Studio math.h...
#ifdef WINCE
#if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED)
#define _MATH_DEFINES_DEFINED
#define M_E 2.71828182845904523536
#define M_LOG2E 1.44269504088896340736
#define M_LOG10E 0.434294481903251827651
#define M_LN2 0.693147180559945309417
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.785398163397448309616
#define M_1_PI 0.318309886183790671538
#define M_2_PI 0.636619772367581343076
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.707106781186547524401
#endif
#endif // WINCE
// The definition of M_PI and M_PI_2 is not in C++ standard, although it is often provided by compilers...
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif // !M_PI
#ifndef M_PI_2
#define M_PI_2 1.57079632679489661923
#endif // !M_PI_2
#ifndef _WIN32
//#ifndef ZeroMemory
#define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
//#endif // !ZeroMemory
typedef void* HANDLE;
//#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
//#endif // !INVALID_HANDLE_VALUE
typedef int BOOL;
#ifndef FALSE
#define FALSE 0
#endif // !FALSE
#ifndef TRUE
#define TRUE 1
#endif // !TRUE
typedef unsigned int u_int;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned int DWORD;
typedef BYTE BOOLEAN;
#endif // !_WIN32
// Might depend on the platform...
#ifndef DISABLE_UINT8_16_32_TYPEDEF
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
#endif // !DISABLE_UINT8_16_32_TYPEDEF
// Conflict with OpenCV...
#ifdef ENABLE_INT64_TYPEDEF
// Note that the long long type is not accepted by Borland C++ Builder 5.
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef int64_t int64;
typedef uint64_t uint64;
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
#endif // ENABLE_INT64_TYPEDEF
#ifndef DISABLE_OLD_MSC_VER_INT_T_TYPEDEF
#if defined(_MSC_VER) || defined(__BORLANDC__)
#if _MSC_VER >= 1600
#else
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif // _MSC_VER >= 1600
#endif // defined(_MSC_VER) || defined(__BORLANDC__)
#endif // !DISABLE_OLD_MSC_VER_INT_T_TYPEDEF
#ifndef _WIN32
typedef union _LARGE_INTEGER {
struct {
unsigned int LowPart;
int HighPart;
};
struct {
unsigned int LowPart;
int HighPart;
} u;
long long QuadPart;
} LARGE_INTEGER;
typedef union _ULARGE_INTEGER {
struct {
unsigned int LowPart;
unsigned int HighPart;
};
struct {
unsigned int LowPart;
unsigned int HighPart;
} u;
unsigned long long QuadPart;
} ULARGE_INTEGER;
#endif // !_WIN32
/*
Structure corresponding to a color in a RGB format (red, green and blue
levels).
*/
struct RGBCOLOR
{
UCHAR r; // Red value.
UCHAR g; // Green value.
UCHAR b; // Blue value.
};
typedef struct RGBCOLOR RGBCOLOR;
inline RGBCOLOR rgbcolor(UCHAR r, UCHAR g, UCHAR b)
{
RGBCOLOR color;
color.r = r; color.g = g; color.b = b;
return color;
}
// If you use Visual Studio in debug configuration, call INIT_DEBUG at the
// beginning of the program to enable memory leaks detection.
// If you do not use Visual Studio, INIT_DEBUG will be ignored.
#if defined(_MSC_VER) && defined(_DEBUG) && !defined(DISABLE_ADDITIONAL_DEBUG_FEATURES)
# ifndef INIT_DEBUG
# define INIT_DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
# endif // INIT_DEBUG
#else
# ifndef INIT_DEBUG
# define INIT_DEBUG
# endif // INIT_DEBUG
#endif // defined(_MSC_VER) && defined(_DEBUG) && !defined(DISABLE_ADDITIONAL_DEBUG_FEATURES)
#ifndef DISABLE_USE_SNPRINTF
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf c99_snprintf
#define vsnprintf c99_vsnprintf
__inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
{
int count = -1;
if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
__inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
{
int count;
va_list ap;
va_start(ap, format);
count = c99_vsnprintf(outBuf, size, format, ap);
va_end(ap);
return count;
}
#endif // defined(_MSC_VER) && _MSC_VER < 1900
#endif // DISABLE_USE_SNPRINTF
/*
enum EXIT_CODE
{
}
*/
// Return values of functions.
// The return value for a Linux program should be between 0 and 127.
// For Windows, at least STILL_ACTIVE (259) should not be used.
#define EXIT_TIMEOUT 2
#define EXIT_INVALID_PARAMETER 3
#define EXIT_INVALID_DATA 4
#define EXIT_NAME_TOO_LONG 5
#define EXIT_OUT_OF_MEMORY 6
#define EXIT_OBJECT_NONSIGNALED 7
#define EXIT_TOO_MANY_SEMAPHORES 8
#define EXIT_KILLED_THREAD 9
#define EXIT_CANCELED_THREAD 10
#define EXIT_IO_PENDING 11
#define EXIT_KILLED_PROCESS 12
#define EXIT_CHANGED 13
#define EXIT_NOT_CHANGED 14
#define EXIT_FOUND 15
#define EXIT_NOT_FOUND 16
#define EXIT_NOT_IMPLEMENTED 17
// Strings corresponding to the previous return values.
EXTERN_C const char* szOSUtilsErrMsgs[];
/*
Format a message corresponding to the last error in a system call (thread-
safe).
char* buf : (INOUT) Valid pointer to a buffer that will receive the message.
int buflen : (IN) Size of the buffer in bytes.
Return : buf.
*/
EXTERN_C char* FormatLastErrorMsg(char* buf, int buflen);
#define LAST_ERROR_MSG_SIZE 256
// Specific macro used with PRINT_DEBUG_MESSAGE, PRINT_DEBUG_WARNING
// or PRINT_DEBUG_ERROR to return the message corresponding to the last error
// in a system call in the current thread.
#define GetLastErrorMsg() FormatLastErrorMsg(szLastErrMsg, LAST_ERROR_MSG_SIZE)
// For Windows, debug is activated if _DEBUG is defined.
// In this case, default is to only activate errors for OSUtils.
#if defined(_DEBUG) && !defined(_DEBUG_MESSAGES) && !defined(_DEBUG_WARNINGS) && !defined(_DEBUG_ERRORS)
#define _DEBUG_ERRORS
#endif // defined(_DEBUG) && !defined(_DEBUG_MESSAGES) && !defined(_DEBUG_WARNINGS) && !defined(_DEBUG_ERRORS)
// If _DEBUG_MESSAGES is defined, messages, warnings and errors are activated.
// If _DEBUG_WARNINGS is defined, only warnings and errors are activated.
// If _DEBUG_ERRORS is defined, only errors are activated.
#ifdef _DEBUG_MESSAGES
# define _DEBUG_WARNINGS
# define _DEBUG_ERRORS
#else
# ifdef _DEBUG_WARNINGS
# define _DEBUG_ERRORS
# endif // _DEBUG_WARNINGS
#endif // _DEBUG_MESSAGES
#if defined(_DEBUG_MESSAGES) || defined(_DEBUG_WARNINGS) || defined(_DEBUG_ERRORS)
// Default is to print on stdout/err
#if !defined(_DEBUG_DISPLAY) && !defined(_DEBUG_FILE)
#define _DEBUG_DISPLAY
#endif // !defined(_DEBUG_DISPLAY) && !defined(_DEBUG_FILE)
#endif // defined(_DEBUG_MESSAGES) || defined(_DEBUG_WARNINGS) || defined(_DEBUG_ERRORS)
#ifdef __GNUC__
// Disable some GCC warnings.
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic push
#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#endif // __GNUC__
#ifdef _DEBUG_DISPLAY
# define PRINT_DEBUG_MESSAGE(params) {char szLastErrMsg[LAST_ERROR_MSG_SIZE];szLastErrMsg[LAST_ERROR_MSG_SIZE-1]=0;fprintf_stdout params;}
# define PRINT_DEBUG_WARNING(params) {char szLastErrMsg[LAST_ERROR_MSG_SIZE];szLastErrMsg[LAST_ERROR_MSG_SIZE-1]=0;fprintf_stdout params;}
# define PRINT_DEBUG_ERROR(params) {char szLastErrMsg[LAST_ERROR_MSG_SIZE];szLastErrMsg[LAST_ERROR_MSG_SIZE-1]=0;fprintf_stderr params;}
#else
# ifdef _DEBUG_FILE
# define PRINT_DEBUG_MESSAGE(params) {char szLastErrMsg[LAST_ERROR_MSG_SIZE];szLastErrMsg[LAST_ERROR_MSG_SIZE-1]=0;fprintf_messages_file params;}
# define PRINT_DEBUG_WARNING(params) {char szLastErrMsg[LAST_ERROR_MSG_SIZE];szLastErrMsg[LAST_ERROR_MSG_SIZE-1]=0;fprintf_warnings_file params;}
# define PRINT_DEBUG_ERROR(params) {char szLastErrMsg[LAST_ERROR_MSG_SIZE];szLastErrMsg[LAST_ERROR_MSG_SIZE-1]=0;fprintf_errors_file params;}
# else
# define PRINT_DEBUG_MESSAGE(params)
# define PRINT_DEBUG_WARNING(params)
# define PRINT_DEBUG_ERROR(params)
# endif // _DEBUG_FILE
#endif // _DEBUG_DISPLAY
#ifdef __GNUC__
// Restore the GCC warnings previously disabled.
#if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#pragma GCC diagnostic pop
#endif // (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6)) || (__GNUC__ > 4))
#endif // __GNUC__
#ifdef _DEBUG_DISPLAY
EXTERN_C void fprintf_stdout(const char * _Format, ...);
EXTERN_C void fprintf_stderr(const char * _Format, ...);
#endif // _DEBUG_DISPLAY
#ifdef _DEBUG_FILE
#ifdef USE_DIFFERENT_FILES_FOR_ERRORS_WARNINGS_AND_MESSAGES
#define MESSAGES_FILENAME "messages.txt"
#define WARNINGS_FILENAME "warnings.txt"
#define ERRORS_FILENAME "errors.txt"
#else
#define MESSAGES_FILENAME "log.txt"
#define WARNINGS_FILENAME "log.txt"
#define ERRORS_FILENAME "log.txt"
#endif // USE_DIFFERENT_FILES_FOR_ERRORS_WARNINGS_AND_MESSAGES
EXTERN_C void fprintf_messages_file(const char * _Format, ...);
EXTERN_C void fprintf_warnings_file(const char * _Format, ...);
EXTERN_C void fprintf_errors_file(const char * _Format, ...);
#endif // _DEBUG_FILE
/*
Debug macros specific to OSUtils.
*/
#ifdef _DEBUG_MESSAGES
# define _DEBUG_MESSAGES_OSUTILS
#endif // _DEBUG_MESSAGES
#ifdef _DEBUG_WARNINGS
# define _DEBUG_WARNINGS_OSUTILS
#endif // _DEBUG_WARNINGS
#ifdef _DEBUG_ERRORS
# define _DEBUG_ERRORS_OSUTILS
#endif // _DEBUG_ERRORS
#ifdef _DEBUG_MESSAGES_OSUTILS
# define PRINT_DEBUG_MESSAGE_OSUTILS(params) PRINT_DEBUG_MESSAGE(params)
#else
# define PRINT_DEBUG_MESSAGE_OSUTILS(params)
#endif // _DEBUG_MESSAGES_OSUTILS
#ifdef _DEBUG_WARNINGS_OSUTILS
# define PRINT_DEBUG_WARNING_OSUTILS(params) PRINT_DEBUG_WARNING(params)
#else
# define PRINT_DEBUG_WARNING_OSUTILS(params)
#endif // _DEBUG_WARNINGS_OSUTILS
#ifdef _DEBUG_ERRORS_OSUTILS
# define PRINT_DEBUG_ERROR_OSUTILS(params) PRINT_DEBUG_ERROR(params)
#else
# define PRINT_DEBUG_ERROR_OSUTILS(params)
#endif // _DEBUG_ERRORS_OSUTILS
/*
Debug macros specific to OSCore.
*/
#ifdef _DEBUG_MESSAGES_OSUTILS
# define _DEBUG_MESSAGES_OSCORE
#endif // _DEBUG_MESSAGES_OSUTILS
#ifdef _DEBUG_WARNINGS_OSUTILS
# define _DEBUG_WARNINGS_OSCORE
#endif // _DEBUG_WARNINGS_OSUTILS
#ifdef _DEBUG_ERRORS_OSUTILS
# define _DEBUG_ERRORS_OSCORE
#endif // _DEBUG_ERRORS_OSUTILS
#ifdef _DEBUG_MESSAGES_OSCORE
# define PRINT_DEBUG_MESSAGE_OSCORE(params) PRINT_DEBUG_MESSAGE(params)
#else
# define PRINT_DEBUG_MESSAGE_OSCORE(params)
#endif // _DEBUG_MESSAGES_OSCORE
#ifdef _DEBUG_WARNINGS_OSCORE
# define PRINT_DEBUG_WARNING_OSCORE(params) PRINT_DEBUG_WARNING(params)
#else
# define PRINT_DEBUG_WARNING_OSCORE(params)
#endif // _DEBUG_WARNINGS_OSCORE
#ifdef _DEBUG_ERRORS_OSCORE
# define PRINT_DEBUG_ERROR_OSCORE(params) PRINT_DEBUG_ERROR(params)
#else
# define PRINT_DEBUG_ERROR_OSCORE(params)
#endif // _DEBUG_ERRORS_OSCORE
#endif // !OSCORE_H