|
OpenTTD Source 20260311-master-g511d3794ce
|
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 | EMPTY_BASES |
| #define | PATHSEP "/" |
| #define | PATHSEPCHAR '/' |
| #define | PACK_N(type_dec, n) |
| #define | PACK(type_dec) |
| #define | debug_inline |
| When making a (pure) debug build, the compiler will by default disable inlining of functions. | |
| #define | PERSONAL_DIR "" |
| #define | M_PI_2 1.57079632679489661923 |
| #define | M_PI 3.14159265358979323846 |
| #define | lengthof(array) |
| Return the length of an fixed size array. | |
| #define | GNU_TARGET(x) |
| #define | JSON_ASSERT(x) |
| #define | MAX_PATH 260 |
Typedefs | |
| typedef unsigned int | uint |
Functions | |
| static std::string | FS2OTTD (std::string_view name) |
| static std::string | OTTD2FS (std::string_view 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 (std::string_view expression, const std::source_location location=std::source_location::current()) |
Definition of base types and functions in a cross-platform compatible way.
Definition in file stdafx.h.
| #define debug_inline |
When making a (pure) debug build, the compiler will by default disable inlining of functions.
This has a detrimental effect on the performance of debug builds, especially when more and more trivial (wrapper) functions get added to the code base. Take for example the savegame called "Wentbourne", when running this game for 100 ticks with the null video driver a number of fairly trivial functions show up on top. The most common one is the implicit conversion operator of TileIndex to unsigned int, which takes up over 5% of the total run time and functionally does absolutely nothing. The remaining functions for the top 5 are GB, GetTileType, Map::Size and IsTileType to a total of about 12.5% of the game's total run time. It is possible to still force inlining in the most commonly used compilers, but that is at the cost of some problems with debugging due to the forced inlining. However, the performance benefit can be enormous; when forcing inlining for the previously mentioned top 5, the debug build ran about 15% quicker. The following debug_inline attribute may be added to functions comply with the following preconditions: 1: the function takes more than 0.5% of a profiled debug runtime 2: the function does not modify the game state 3: the function does not contain selection or iteration statements, i.e. no if, switch, for, do, while, etcetera. 4: the function is one line of code, excluding assertions. 5: the function is defined in a header file. The debug_inline attribute must be placed in front of the function, i.e. before the optional static or constexpr modifier.
Definition at line 222 of file stdafx.h.
Referenced by GB(), GoodsEntry::GetData(), GoodsEntry::GetData(), GetRailTileType(), GetRoadTileType(), GetTileType(), HasBit(), GoodsEntry::HasData(), HasFlag(), Tile::height(), Vehicle::IsFrontEngine(), Vehicle::IsGroundVehicle(), IsNormalRoad(), IsNormalRoadTile(), IsPlainRail(), IsPlainRailTile(), IsRailDepot(), IsRailDepotTile(), IsRoadDepot(), IsRoadDepotTile(), IsTileType(), Map::LogX(), Tile::m1(), Tile::m2(), Tile::m3(), Tile::m4(), Tile::m5(), Tile::m6(), Tile::m7(), Tile::m8(), Map::MaxX(), Tile::operator TileIndex(), Tile::operator uint(), Map::Size(), Map::SizeX(), Tile::Tile(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), ToggleFlag(), and Tile::type().
| #define lengthof | ( | array | ) |
Return the length of an fixed size array.
Unlike sizeof this function returns the number of elements of the given type.
| array | The pointer to the first element of the array |
Definition at line 271 of file stdafx.h.
Referenced by AddAcceptedCargoOfHouse(), AddGenericCallback(), AppendFile(), BuildLandLegend(), BuildLinkStatsLegend(), BulldozerTick(), CmdFoundTown(), CargoesRow::ConnectIndustryAccepted(), DetermineBasePaths(), DrawBridgeRoadBits(), LinkGraphOverlay::DrawContent(), DrawTile_Trees(), ExtractTar(), FillNewGRFVehicleCache(), FinaliseHouseArray(), CoreTextFontCacheFactory::FindFallbackFont(), FixTTOEngines(), FormatBytes(), FormatString(), FreeTerminal(), AirportSpec::Get(), AirportTileSpec::Get(), CargoSpec::Get(), GetAllCargoSuffixes(), CargoSpec::GetArraySize(), GetBridgeSpec(), NWidgetMainToolbarContainer::GetButtonArrangement(), NWidgetScenarioToolbarContainer::GetButtonArrangement(), GetFileTitle(), GetMaxTreeSpriteSize(), GetNewgrfCurrencyIdConverted(), GetNumberOfIndustries(), GetTextfile(), GetVelocityUnits(), NetworkChatWindow::GetWidgetString(), AirportSpec::GetWithoutOverride(), StringReader::HandlePragma(), IndustryCargoesWindow::HousesCanAccept(), IndustriesChangeInfo(), OpenGLBackend::InitShaders(), SmallSet< Tdir, items >::IsFull(), Vehicle::LoadOldVehicle, MakeHeightmapScreenshot(), MakePerformanceDetailPanels(), MidiGetStandardSysexMessage(), NetworkGameLoop(), NetworkServerShowStatusToConsole(), SmallMapWindow::OnInit(), OutputContentState(), ResetObjects(), RunTileLoop(), SmallMapWindow::SetZoomLevel(), CrashLogOSX::SurveyStacktrace(), CrashLogUnix::SurveyStacktrace(), and TownHouseChangeInfo().
| #define PACK_N | ( | type_dec, | |
| n ) |
| void AssertFailedError | ( | std::string_view | expression, |
| const std::source_location | location = std::source_location::current() ) |
| void NOT_REACHED | ( | const std::source_location | location = std::source_location::current() | ) |