OpenTTD Source: src/stdafx.h File Reference

OpenTTD Source 15.0-beta1

Macros | Typedefs | Functions
stdafx.h File Reference

Definition of base types and functions in a cross-platform compatible way. More...

`#include <stdint.h>`
`#include <algorithm>`
`#include <array>`
`#include <bit>`
`#include <cassert>`
`#include <cctype>`
`#include <cerrno>`
`#include <climits>`
`#include <cmath>`
`#include <cstddef>`
`#include <cstdint>`
`#include <cstdio>`
`#include <cstring>`
`#include <cstdlib>`
`#include <cwchar>`
`#include <deque>`
`#include <exception>`
`#include <functional>`
`#include <iterator>`
`#include <list>`
`#include <limits>`
`#include <map>`
`#include <memory>`
`#include <numeric>`
`#include <optional>`
`#include <set>`
`#include <source_location>`
`#include <span>`
`#include <stdexcept>`
`#include <string>`
`#include <type_traits>`
`#include <variant>`
`#include <vector>`

Go to the source code of this file.

## Macros
#define | __STDC_LIMIT_MACROS
#define | NOACCESS(args)
#define | EMPTY_BASES
#define | PATHSEP "/"
#define | PATHSEPCHAR '/'
#define | PACK_N(type_dec, n) type_dec __attribute__((__packed__, aligned(n)))
#define | PACK(type_dec) PACK_N(type_dec, 1)
#define | debug_inline inline
#define | PERSONAL_DIR ""
#define | M_PI_2 1.57079632679489661923
#define | M_PI 3.14159265358979323846
#define | lengthof(array) (sizeof(ArraySizeHelper(array)))
| Return the length of an fixed size array.
#define | cpp_sizeof(base, variable) (sizeof(std::declval<base>().variable))
| Gets the size of a variable within a class.
#define | GNU_TARGET(x)
#define | FMT_HEADER_ONLY
#define | JSON_ASSERT(x) assert(x)
#define | MAX_PATH 260
#define | MAX_UVALUE(type) (static_cast<type>(~static_cast<type>(0)))
| The largest value that can be entered in a variable.
#define | IGNORE_UNINITIALIZED_WARNING_START
#define | IGNORE_UNINITIALIZED_WARNING_STOP

## Typedefs
typedef unsigned int | uint

## Functions
template<typename T >
std::string | FS2OTTD (T name)
template<typename T >
std::string | OTTD2FS (T name)
template<typename T , size_t N>
char(& | ArraySizeHelper (T(&array)[N]))[N]
void | NOT_REACHED (const std::source_location location=std::source_location::current())
void | AssertFailedError (const char *expression, const std::source_location location=std::source_location::current())
void | free (const void *ptr)
| Version of the standard free that accepts const pointers.

## Detailed Description

Definition of base types and functions in a cross-platform compatible way.

Definition in file stdafx.h.

## Macro Definition Documentation

## ◆ __STDC_LIMIT_MACROS

#define __STDC_LIMIT_MACROS

Definition at line 35 of file stdafx.h.

## ◆ cpp_sizeof

#define cpp_sizeof | ( |  | base,
|  |  | variable
| ) |  | (sizeof(std::declval<base>().variable))

Gets the size of a variable within a class.

Parameters

  base | The class the variable is in.
  variable | The variable to get the size of.

Returns
  the size of the variable

Definition at line 288 of file stdafx.h.

## ◆ debug_inline

#define debug_inline inline

Definition at line 231 of file stdafx.h.

## ◆ EMPTY_BASES

#define EMPTY_BASES

Definition at line 102 of file stdafx.h.

## ◆ FMT_HEADER_ONLY

#define FMT_HEADER_ONLY

Definition at line 305 of file stdafx.h.

## ◆ GNU_TARGET

#define GNU_TARGET | ( |  | x | ) |

Definition at line 301 of file stdafx.h.

## ◆ IGNORE_UNINITIALIZED_WARNING_START

#define IGNORE_UNINITIALIZED_WARNING_START

Definition at line 362 of file stdafx.h.

## ◆ IGNORE_UNINITIALIZED_WARNING_STOP

#define IGNORE_UNINITIALIZED_WARNING_STOP

Definition at line 363 of file stdafx.h.

## ◆ JSON_ASSERT

#define JSON_ASSERT | ( |  | x | ) | assert(x)

Definition at line 318 of file stdafx.h.

## ◆ lengthof

#define lengthof | ( |  | array | ) | (sizeof(ArraySizeHelper(array)))

Return the length of an fixed size array.

Unlike sizeof this function returns the number of elements of the given type.

Parameters

  x | The pointer to the first element of the array

Returns
  The number of elements

Definition at line 280 of file stdafx.h.

## ◆ M_PI

#define M_PI 3.14159265358979323846

Definition at line 266 of file stdafx.h.

## ◆ M_PI_2

#define M_PI_2 1.57079632679489661923

Definition at line 265 of file stdafx.h.

## ◆ MAX_PATH

#define MAX_PATH 260

Definition at line 327 of file stdafx.h.

## ◆ MAX_UVALUE

#define MAX_UVALUE | ( |  | type | ) | (static_cast<type>(~static_cast<type>(0)))

The largest value that can be entered in a variable.

Parameters

  type | the type of the variable

Definition at line 343 of file stdafx.h.

## ◆ NOACCESS

#define NOACCESS | ( |  | args | ) |

Definition at line 91 of file stdafx.h.

## ◆ PACK

#define PACK | ( |  | type_dec | ) | PACK_N(type_dec, 1)

Definition at line 196 of file stdafx.h.

## ◆ PACK_N

#define PACK_N | ( |  | type_dec,
|  |  | n
| ) |  | type_dec __attribute__((__packed__, aligned(n)))

Definition at line 194 of file stdafx.h.

## ◆ PATHSEP

#define PATHSEP "/"

Definition at line 184 of file stdafx.h.

## ◆ PATHSEPCHAR

#define PATHSEPCHAR '/'

Definition at line 185 of file stdafx.h.

## ◆ PERSONAL_DIR

#define PERSONAL_DIR ""

Definition at line 249 of file stdafx.h.

## Typedef Documentation

## ◆ uint

typedef unsigned int uint

Definition at line 245 of file stdafx.h.

## Function Documentation

## ◆ AssertFailedError()

void AssertFailedError | ( | const char * | expression,
|  | const std::source_location | location = `std::source_location::current()`
| ) |  |

Definition at line 18 of file error.cpp.

## ◆ free()

void free | ( | const void * | ptr | ) |
| inline

Version of the standard free that accepts const pointers.

Parameters

  ptr | The data to free.

Definition at line 334 of file stdafx.h.

References free().

Referenced by ReusableBuffer< T >::Allocate(), Map::Allocate(), ScriptAllocator::CheckAllocation(), ClearSnowLine(), DEFINE_POOL_METHOD(), free(), FreeEngine(), Path::GetCapacityRatio(), GetLayouter(), InitializeOldNames(), OpenGLBackend::InternalClearCursorCache(), ZeroedMemoryAllocator::operator delete(), ZeroedMemoryAllocator::operator delete[](), Blitter_32bppAnim::PostResize(), ReallocT(), ResetBridges(), ResetOldNames(), StringFilter::SetFilterTerm(), VideoDriver_Dedicated::Stop(), CrashLogOSX::SurveyStacktrace(), CrashLogUnix::SurveyStacktrace(), ReusableBuffer< T >::ZeroAllocate(), and ReusableBuffer< T >::~ReusableBuffer().

## ◆ FS2OTTD()

template<typename T >

std::string FS2OTTD | ( | T | name | ) |

Definition at line 175 of file stdafx.h.

## ◆ NOT_REACHED()

void NOT_REACHED | ( | const std::source_location | location = `std::source_location::current()` | ) |

Definition at line 13 of file error.cpp.

## ◆ OTTD2FS()

template<typename T >

std::string OTTD2FS | ( | T | name | ) |

Definition at line 176 of file stdafx.h.