OpenTTD Source: src/safeguards.h Source File

OpenTTD Source 15.0-beta1

safeguards.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
19#ifndef SAFEGUARDS_H
20#define SAFEGUARDS_H
21
22/* Use MallocT instead. */
23#define malloc SAFEGUARD_DO_NOT_USE_THIS_METHOD
24
25/* Use MallocT instead. */
26#define calloc SAFEGUARD_DO_NOT_USE_THIS_METHOD
27
28/* Use ReallocT instead. */
29#define realloc SAFEGUARD_DO_NOT_USE_THIS_METHOD
30
31/* Use std::string instead. */
32#define strdup SAFEGUARD_DO_NOT_USE_THIS_METHOD
33#define strndup SAFEGUARD_DO_NOT_USE_THIS_METHOD
34
35/* Use strecpy instead. */
36#define strcpy SAFEGUARD_DO_NOT_USE_THIS_METHOD
37#define strncpy SAFEGUARD_DO_NOT_USE_THIS_METHOD
38
39/* Use std::string concatenation/fmt::format instead. */
40#define strcat SAFEGUARD_DO_NOT_USE_THIS_METHOD
41#define strncat SAFEGUARD_DO_NOT_USE_THIS_METHOD
42
43/* Use fmt::format instead. */
44#define sprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
45#define snprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
46
47/* Use fmt::format instead. */
48#define vsprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
49#define vsnprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
50
51/* Use fgets instead. */
52#define gets SAFEGUARD_DO_NOT_USE_THIS_METHOD
53
54/* No clear replacement. */
55#define strtok SAFEGUARD_DO_NOT_USE_THIS_METHOD
56
57/* Use fmt::print instead. */
58#define printf SAFEGUARD_DO_NOT_USE_THIS_METHOD
59#define fprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
60#define puts SAFEGUARD_DO_NOT_USE_THIS_METHOD
61#define fputs SAFEGUARD_DO_NOT_USE_THIS_METHOD
62#define putchar SAFEGUARD_DO_NOT_USE_THIS_METHOD
63
64/* Use our own templated implementation instead of a macro or function with only one type. */
65#ifdef min
66#undef min
67#endif
68
69/* Use our own templated implementation instead of a macro or function with only one type. */
70#ifdef max
71#undef max
72#endif
73
74/* Use our own templated implementation instead of a macro or function with only one type. */
75#ifdef abs
76#undef abs
77#endif
78
79#if defined(NETWORK_CORE_OS_ABSTRACTION_H) && defined(_WIN32)
80/* Use NetworkError::GetLast() instead of errno, or do not (indirectly) include network/core/os_abstraction.h.
81 * Winsock does not set errno, but one should rather call WSAGetLastError. NetworkError::GetLast abstracts that away. */
82#ifdef errno
83#undef errno
84#endif
85#define errno SAFEGUARD_DO_NOT_USE_THIS_METHOD
86
87/* Use NetworkError::AsString() instead of strerror, or do not (indirectly) include network/core/os_abstraction.h.
88 * Winsock errors are not handled by strerror, but one should rather call FormatMessage. NetworkError::AsString abstracts that away. */
89#define strerror SAFEGUARD_DO_NOT_USE_THIS_METHOD
90#endif /* defined(NETWORK_CORE_OS_ABSTRACTION_H) && defined(_WIN32) */
91
92#endif /* SAFEGUARDS_H */