libtcod
Loading...
Searching...
No Matches
config.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_CONFIG_H_
36#define LIBTCOD_CONFIG_H_
37
38/* DLL export */
39#ifndef TCODLIB_API
40#ifdef LIBTCOD_STATIC
41#define TCODLIB_API
42#elif defined _WIN32 || defined __CYGWIN__ || defined __MINGW32__
43#ifdef LIBTCOD_EXPORTS
44#ifdef __GNUC__
45#define TCODLIB_API __attribute__((dllexport))
46#else
47#define TCODLIB_API __declspec(dllexport)
48#endif // __GNUC__
49#else
50#ifdef __GNUC__
51#define TCODLIB_API __attribute__((dllimport))
52#else
53#define TCODLIB_API __declspec(dllimport)
54#endif // __GNUC__
55#endif // LIBTCOD_EXPORTS
56#elif __GNUC__ >= 4
57#define TCODLIB_API __attribute__((visibility("default")))
58#else
59#define TCODLIB_API
60#endif
61#endif // TCODLIB_API
62
63#ifndef TCODLIB_API_INLINE_EXPORT
64#ifdef LIBTCOD_EXPORTS
66#define TCODLIB_API_INLINE_EXPORT TCODLIB_API
67#else
68#define TCODLIB_API_INLINE_EXPORT
69#endif
70#endif // TCODLIB_API_INLINE_EXPORT
71
72#ifndef TCODLIB_CAPI
73#ifdef __cplusplus
74#define TCODLIB_CAPI extern "C" TCODLIB_API
75#else
76#define TCODLIB_CAPI TCODLIB_API
77#endif // __cplusplus
78#endif // TCODLIB_CAPI
79
80// Publicly visible symbols and functions.
81#define TCOD_PUBLIC TCODLIB_API
82
83// Private hidden symbols.
84#if __GNUC__ >= 4
85#define TCOD_PRIVATE __attribute__((visibility("hidden")))
86#else
87#define TCOD_PRIVATE
88#endif // __GNUC__ >= 4
89
90// Cross platform deprecation.
91#ifdef TCOD_IGNORE_DEPRECATED
92#define TCOD_DEPRECATED(msg)
93#define TCOD_DEPRECATED_NOMESSAGE
94#define TCOD_DEPRECATED_ENUM
95#elif defined(__cplusplus) && __cplusplus >= 201402L && !defined(__clang__)
96#define TCOD_DEPRECATED(msg) [[deprecated(msg)]]
97#define TCOD_DEPRECATED_NOMESSAGE [[deprecated]]
98#define TCOD_DEPRECATED_ENUM [[deprecated]]
99#elif defined(_MSC_VER)
100#define TCOD_DEPRECATED(msg) __declspec(deprecated(msg))
101#define TCOD_DEPRECATED_NOMESSAGE __declspec(deprecated)
102#define TCOD_DEPRECATED_ENUM
103#elif defined(__GNUC__)
104#define TCOD_DEPRECATED(msg) __attribute__((deprecated(msg)))
105#define TCOD_DEPRECATED_NOMESSAGE __attribute__((deprecated))
106#define TCOD_DEPRECATED_ENUM __attribute__((deprecated))
107#else
108#define TCOD_DEPRECATED(msg)
109#define TCOD_DEPRECATED_NOMESSAGE
110#define TCOD_DEPRECATED_ENUM
111#endif
112
113#ifdef __GNUC__
114// Tells GCC the these functions are printf-like.
115#define TCODLIB_PRINTF(str_index, first_arg) __attribute__((format(printf, str_index, first_arg)))
116#else
117#define TCODLIB_PRINTF(str_index, first_arg)
118#endif
119
120#define TCODLIB_FORMAT TCODLIB_PRINTF
121
122#if defined(__cplusplus) && __cplusplus >= 201703L && !defined(__clang__)
123#define TCOD_NODISCARD [[nodiscard]]
124#elif defined(_MSC_VER)
125#define TCOD_NODISCARD
126#elif defined(__GNUC__)
127#define TCOD_NODISCARD __attribute__((warn_unused_result))
128#else
129#define TCOD_NODISCARD
130#endif
131
132#ifdef __GNUC__
134#define TCODLIB_BEGIN_IGNORE_DEPRECATIONS \
135 _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \
136 _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
137#define TCODLIB_END_IGNORE_DEPRECATIONS _Pragma("GCC diagnostic pop")
138#elif defined(_MSC_VER)
139#define TCODLIB_BEGIN_IGNORE_DEPRECATIONS _Pragma("warning(push)") _Pragma("warning(disable : 4996)")
140#define TCODLIB_END_IGNORE_DEPRECATIONS _Pragma("warning(pop)")
141#else
142#define TCODLIB_BEGIN_IGNORE_DEPRECATIONS
143#define TCODLIB_END_IGNORE_DEPRECATIONS
144#endif
145
146#ifndef TCOD_FALLBACK_FONT_SIZE
147// The default height of the fallback font size in pixels.
148#define TCOD_FALLBACK_FONT_SIZE 16
149#endif // TCOD_FALLBACK_FONT_SIZE
150
151#endif // LIBTCOD_CONFIG_H_