libtcod
Loading...
Searching...
No Matches
portability.h
Go to the documentation of this file.
1/* BSD 3-Clause License
2 *
3 * Copyright © 2008-2025, Jice and the libtcod contributors.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
34#pragma once
35#ifndef LIBTCOD_PORTABILITY_H
36#define LIBTCOD_PORTABILITY_H
37#include "config.h"
38/* uncomment to disable unicode support */
39/*#define NO_UNICODE */
40
41/* uncomment to disable opengl support */
42/*#define NO_OPENGL */
43
44/* os identification
45 TCOD_WINDOWS : OS is windows
46 TCOD_LINUX : OS is Linux
47 TCOD_MACOSX : OS is Mac OS X
48 TCOD_HAIKU : OS is Haiku */
49
50/* compiler identification
51 TCOD_VISUAL_STUDIO : compiler is Microsoft Visual Studio
52 TCOD_MINGW32 : compiler is Mingw32
53 TCOD_GCC : compiler is gcc/g++ */
54
55/* word size
56 TCOD_64BITS : 64 bits OS
57 TCOD_WIN64 : 64 bits Windows
58 TCOD_WIN32 : 32 bits Windows
59 TCOD_LINUX64 : 64 bits Linux
60 TCOD_LINUX32 : 32 bits Linux
61 TCOD_FREEBSD64 : 64 bits FreeBSD
62 TCOD_FREEBSD32 : 32 bits FreeBSD */
63
64#if defined(_MSC_VER)
65#define TCOD_VISUAL_STUDIO
66#define TCOD_WINDOWS
67#ifdef _WIN64
68#define TCOD_WIN64
69#define TCOD_64BITS
70#else
71#define TCOD_WIN32
72#endif
73#elif defined(__MINGW32__)
74#define TCOD_WINDOWS
75#define TCOD_MINGW32
76#ifdef _WIN64
77#define TCOD_WIN64
78#define TCOD_64BITS
79#else
80#define TCOD_WIN32
81#endif
82#elif defined(__HAIKU__)
83#define TCOD_HAIKU
84#define TCOD_GCC
85#if __WORDSIZE == 64
86#define TCOD_64BITS
87#endif
88#elif defined(__linux)
89#define TCOD_LINUX
90#define TCOD_GCC
91#if __WORDSIZE == 64
92#define TCOD_LINUX64
93#define TCOD_64BITS
94#else
95#define TCOD_LINUX32
96#endif
97#elif defined(__FreeBSD__)
98#define TCOD_FREEBSD
99#define TCOD_GCC
100#if __WORDSIZE == 64
101#define TCOD_FREEBSD64
102#define TCOD_64BITS
103#else
104#define TCOD_FREEBSD32
105#endif
106#elif defined(__APPLE__) && defined(__MACH__)
107#define TCOD_MACOSX
108#define TCOD_GCC
109#if __WORDSIZE == 64
110#define TCOD_64BITS
111#endif
112#endif
113
114/* unicode rendering functions support */
115#ifndef NO_UNICODE
116#include <wchar.h>
117#endif
118
119/* int types */
120#include <stdint.h>
121
122/* bool type */
123#include <stdbool.h>
124
128TCODLIB_CAPI char* TCOD_strdup(const char* s);
129
132TCODLIB_CAPI int TCOD_strcasecmp(const char* s1, const char* s2);
133
136TCODLIB_CAPI int TCOD_strncasecmp(const char* s1, const char* s2, size_t n);
137
138/* Define vswprintf across platforms. */
139#ifdef _WIN32
140#define vswprintf _vsnwprintf /* Windows */
141#endif /* _WIN32 */
142#endif /* LIBTCOD_PORTABILITY_H */
Libtcod config header.
int TCOD_strcasecmp(const char *s1, const char *s2)
Compare two ASCII strings ignoring case.
int TCOD_strncasecmp(const char *s1, const char *s2, size_t n)
Compare two ASCII strings ignoring case.
char * TCOD_strdup(const char *s)
Allocate and return a duplicate of string s.