FreeBASIC  0.91.0
fb_win32.h
Go to the documentation of this file.
1 #ifdef HOST_MINGW
2 #include <malloc.h> /* for _alloca() */
3 
4 /* not MinGW-w64? It already has ssize_t instead of _ssize_t */
5 #ifndef __MINGW64_VERSION_MAJOR
6  /* for _ssize_t with MinGW.org toolchain under -D_NO_OLDNAMES */
7  #include <sys/types.h>
8  #define ssize_t _ssize_t
9 #endif
10 
11 /* These defines let us use the same code for all platforms while still mapping
12  to the proper win32 functions. Of those, we prefer to use the non-oldnames
13  versions, which is also why we #define NO_OLDNAMES and _NO_OLDNAMES.
14  However, this sort of re-defining should only be used for functions that
15  are used more than once, for the others #ifdef should do */
16 #define snprintf _snprintf
17 #define strdup(s) _strdup(s)
18 #define strcasecmp(a, b) _stricmp(a, b)
19 #define strncasecmp(a, b, n) _strnicmp(a, b, n)
20 #define alloca(x) _alloca(x)
21 #endif
22 
23 #ifdef HOST_X86
24 #define FBCALL __stdcall
25 #else
26 #define FBCALL
27 #endif
28 
29 /* newline for console/file I/O */
30 #define FB_NEWLINE "\r\n"
31 #define FB_NEWLINE_WSTR _LC("\r\n")
32 
33 /* newline for printer I/O */
34 #define FB_BINARY_NEWLINE "\r\n"
35 #define FB_BINARY_NEWLINE_WSTR _LC("\r\n")
36 
37 #ifdef HOST_CYGWIN
38 #define FB_LL_FMTMOD "ll"
39 #else
40 #define FB_LL_FMTMOD "I64"
41 #endif
42 
43 #define FB_CONSOLE_MAXPAGES 4
44 
45 #ifdef HOST_CYGWIN
46 typedef off_t fb_off_t;
47 #else
48 /* MinGW-w64 recognizes -D_FILE_OFFSET_BITS=64, but MinGW does not, so we
49  can't be sure that ftello() really maps to the 64bit version...
50  so we have to do it manually. */
51 typedef long long fb_off_t;
52 #define fseeko(stream, offset, whence) fseeko64(stream, offset, whence)
53 #define ftello(stream) ftello64(stream)
54 #endif
55 
56 #define FB_COLOR_BLACK (0)
57 #define FB_COLOR_BLUE (FOREGROUND_BLUE)
58 #define FB_COLOR_GREEN (FOREGROUND_GREEN)
59 #define FB_COLOR_CYAN (FOREGROUND_GREEN|FOREGROUND_BLUE)
60 #define FB_COLOR_RED (FOREGROUND_RED)
61 #define FB_COLOR_MAGENTA (FOREGROUND_RED|FOREGROUND_BLUE)
62 #define FB_COLOR_BROWN (FOREGROUND_RED|FOREGROUND_GREEN)
63 #define FB_COLOR_WHITE (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE)
64 #define FB_COLOR_GREY (FOREGROUND_INTENSITY)
65 #define FB_COLOR_LBLUE (FOREGROUND_BLUE|FOREGROUND_INTENSITY)
66 #define FB_COLOR_LGREEN (FOREGROUND_GREEN|FOREGROUND_INTENSITY)
67 #define FB_COLOR_LCYAN (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY)
68 #define FB_COLOR_LRED (FOREGROUND_RED|FOREGROUND_INTENSITY)
69 #define FB_COLOR_LMAGENTA (FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY)
70 #define FB_COLOR_YELLOW (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY)
71 #define FB_COLOR_BWHITE (FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY)
72 
73 #ifdef ENABLE_MT
74  FBCALL void fb_MtLock( void );
75  FBCALL void fb_MtUnlock( void );
76  #define FB_MTLOCK() fb_MtLock()
77  #define FB_MTUNLOCK() fb_MtUnlock()
78 #else
79  #define FB_MTLOCK()
80  #define FB_MTUNLOCK()
81 #endif