OpenTTD Source  12.0-beta2
stdafx.h File Reference
#include <stdint.h>
#include <algorithm>
#include <cstdio>
#include <cstddef>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cassert>
#include <memory>
#include <string>

Go to the source code of this file.

Macros

#define __STDC_LIMIT_MACROS
 
#define UINT64_MAX   (18446744073709551615ULL)
 
#define INT64_MAX   (9223372036854775807LL)
 
#define INT64_MIN   (-INT64_MAX - 1)
 
#define UINT32_MAX   (4294967295U)
 
#define INT32_MAX   (2147483647)
 
#define INT32_MIN   (-INT32_MAX - 1)
 
#define UINT16_MAX   (65535U)
 
#define INT16_MAX   (32767)
 
#define INT16_MIN   (-INT16_MAX - 1)
 
#define UINT8_MAX   (255)
 
#define INT8_MAX   (127)
 
#define INT8_MIN   (-INT8_MAX - 1)
 
#define SIZE_MAX   ((size_t)-1)
 
#define NOACCESS(args)
 
#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 OTTD_PRINTF64   "%lld"
 
#define OTTD_PRINTFHEX64   "%llx"
 
#define PRINTF_SIZE   "%zu"
 
#define PRINTF_SIZEX   "%zX"
 
#define PERSONAL_DIR   ""
 
#define M_PI_2   1.57079632679489661923
 
#define M_PI   3.14159265358979323846
 
#define lengthof(x)   (sizeof(x) / sizeof(x[0]))
 Return the length of an fixed size array. More...
 
#define endof(x)   (&x[lengthof(x)])
 Get the end element of an fixed size array. More...
 
#define lastof(x)   (&x[lengthof(x) - 1])
 Get the last element of an fixed size array. More...
 
#define cpp_sizeof(base, variable)   (sizeof(std::declval<base>().variable))
 Gets the size of a variable within a class. More...
 
#define cpp_lengthof(base, variable)   (cpp_sizeof(base, variable) / cpp_sizeof(base, variable[0]))
 Gets the length of an array variable within a class. More...
 
#define likely(x)   (x)
 
#define unlikely(x)   (x)
 
#define FMT_HEADER_ONLY
 
#define NOT_REACHED()   error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
 
#define MAX_PATH   260
 
#define MAX_UVALUE(type)   ((type)~(type)0)
 The largest value that can be entered in a variable. More...
 
#define IGNORE_UNINITIALIZED_WARNING_START
 
#define IGNORE_UNINITIALIZED_WARNING_STOP
 

Typedefs

typedef unsigned char byte
 
typedef unsigned int uint
 
typedef unsigned char uint8
 
typedef signed char int8
 
typedef unsigned short uint16
 
typedef signed short int16
 
typedef unsigned int uint32
 
typedef signed int int32
 
typedef unsigned __int64 uint64
 
typedef signed __int64 int64
 

Functions

template<typename T >
std::string FS2OTTD (T name)
 
template<typename T >
std::string OTTD2FS (T name)
 
void NORETURN CDECL usererror (const char *str,...) WARN_FORMAT(1
 
void NORETURN CDECL void NORETURN CDECL error (const char *str,...) WARN_FORMAT(1
 
static void free (const void *ptr)
 Version of the standard free that accepts const pointers. More...
 

Detailed Description

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

Definition in file stdafx.h.

Macro Definition Documentation

◆ cpp_lengthof

#define cpp_lengthof (   base,
  variable 
)    (cpp_sizeof(base, variable) / cpp_sizeof(base, variable[0]))

Gets the length of an array variable within a class.

Parameters
baseThe class the variable is in.
variableThe array variable to get the size of.
Returns
the length of the array

Definition at line 410 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
baseThe class the variable is in.
variableThe variable to get the size of.
Returns
the size of the variable

Definition at line 402 of file stdafx.h.

◆ endof

#define endof (   x)    (&x[lengthof(x)])

Get the end element of an fixed size array.

Parameters
xThe pointer to the first element of the array
Returns
The pointer past to the last element of the array

Definition at line 386 of file stdafx.h.

◆ lastof

#define lastof (   x)    (&x[lengthof(x) - 1])

Get the last element of an fixed size array.

Parameters
xThe pointer to the first element of the array
Returns
The pointer to the last element of the array

Definition at line 394 of file stdafx.h.

◆ lengthof

#define lengthof (   x)    (sizeof(x) / sizeof(x[0]))

Return the length of an fixed size array.

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

Parameters
xThe pointer to the first element of the array
Returns
The number of elements

Definition at line 378 of file stdafx.h.

◆ MAX_UVALUE

#define MAX_UVALUE (   type)    ((type)~(type)0)

The largest value that can be entered in a variable.

Parameters
typethe type of the variable

Definition at line 469 of file stdafx.h.

Function Documentation

◆ free()

static void free ( const void *  ptr)
inlinestatic

Version of the standard free that accepts const pointers.

Parameters
ptrThe data to free.

Definition at line 460 of file stdafx.h.

Referenced by AllocateMap(), SmallMatrix< BaseEdge >::Assign(), ScriptConfig::Change(), NetworkChatWindow::ChatTabCompletion(), BinaryHeap::Clear(), GroupStatistics::Clear(), LoadCheckData::Clear(), Hash::Clear(), PersistentStorageArray< int32, 256 >::ClearChanges(), ScriptConfig::ClearConfigList(), TrueTypeFontCache::ClearFontCache(), SpriteFontCache::ClearGlyphToSpriteMap(), ClearSnowLine(), ClearTemporaryNewGRFData(), CmdSetGoalProgress(), CmdSetGoalText(), CmdSetStoryPageTitle(), ErrorMessageData::CopyOutDParams(), DEF_CONSOLE_CMD(), DEFINE_NEWGRF_CLASS_METHOD(), DEFINE_POOL_METHOD(), Hash::Delete(), Hash::DeleteValue(), BinaryHeap::Free(), FreeEngine(), LangString::FreeTranslation(), GamelogFree(), GamelogGRFUpdate(), Path::GetCapacityRatio(), GetLayouter(), Gunzip(), HeightMapAdjustWaterLevel(), InitializeOldNames(), OpenGLBackend::InternalClearCursorCache(), IsGoodGRFConfigList(), IniLoadFile::LoadFromDisk(), CrashLogUnix::LogStacktrace(), NetworkHTTPContentConnecter::OnFailure(), ZeroedMemoryAllocator::operator delete(), ZeroedMemoryAllocator::operator delete[](), SmallMatrix< BaseEdge >::Reset(), ScriptScanner::Reset(), ResetCustomAirports(), ResetCustomHouses(), ResetCustomIndustries(), ResetCustomObjects(), ResetCustomStations(), ScriptConfig::ResetEditableSettings(), ResetOldNames(), ScriptConfig::ResetSettings(), ErrorMessageData::SetDParamStr(), StringFilter::SetFilterTerm(), SlError(), VideoDriver_Dedicated::Stop(), MusicDriver_ExtMidi::Stop(), ScriptConfig::StringToSettings(), ScanProgressWindow::UpdateNewGRFScanStatus(), UpdateOSKOriginalText(), BaseSet< GraphicsSet, MAX_GFT, true >::~BaseSet(), ByteBuffer::~ByteBuffer(), Case::~Case(), ErrorMessageData::~ErrorMessageData(), FallbackParagraphLayout::FallbackVisualRun::~FallbackVisualRun(), FileWriter::~FileWriter(), FixedSizeArray< SubArray, 1024 >::~FixedSizeArray(), FreeUnitIDGenerator::~FreeUnitIDGenerator(), Goal::~Goal(), GRFConfig::~GRFConfig(), HeaderFileWriter::~HeaderFileWriter(), IConsoleLine::~IConsoleLine(), LangString::~LangString(), NetworkHTTPContentConnecter::~NetworkHTTPContentConnecter(), NetworkHTTPSocketHandler::~NetworkHTTPSocketHandler(), OverrideManagerBase::~OverrideManagerBase(), PersistentStorageArray< int32, 256 >::~PersistentStorageArray(), QueryString::~QueryString(), ReusableBuffer< SpriteLoader::CommonPixel >::~ReusableBuffer(), ScanProgressWindow::~ScanProgressWindow(), ScriptConfig::~ScriptConfig(), StoryPage::~StoryPage(), StoryPageElement::~StoryPageElement(), StringData::~StringData(), StringReader::~StringReader(), and TrueTypeFontCache::~TrueTypeFontCache().