MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
core.hpp File Reference
#include <cerrno>
#include <cpptrace/cpptrace.hpp>
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
Include dependency graph for core/mtcore/core.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mtcore::overload< Ts >
 Visit overload pattern for std::variant. More...
 

Namespaces

namespace  mtcore
 Core library for C++ with Zig-related functionality.
 

Macros

#define MTCORE_CORE_HPP
 
#define EXIT_MAX   255
 Maximum exit code value.
 
#define EXIT_ABORT   EXIT_MAX
 Exit code value to indicate program was aborted due to invalid state (e.g.
 
#define mt_print_cur_stacktrace(...)
 Prints the current stack trace with an optional message.
 
#define mt_print_stacktrace(TRACE, ...)
 Prints a specific stack trace with an optional message.
 
#define not_implemented()
 Stub for code that's not implemented Will crash the program if reached in debug mode Will stop compilation if in release mode.
 
#define print_debug(fmt, ...)
 Prints a debug message when in debug mode.
 
#define ensure(check, ...)
 Ensures that a check holds true, aborts the program if not true Will print error if the condition is false.
 
#define unreachable(...)
 Marks code as unreachable.
 
#define mtcore_warn_trace(...)
 Prints a warning message in debug builds Does nothing in release builds`.
 
#define mtcore_warn(...)
 Prints a warning message and stacktrace in debug builds Does nothing in release builds`.
 
#define DEFER_(LINE)
 
#define DEFER(LINE)
 
#define mtdefer   auto DEFER(__LINE__) = mtcore::defer_impl::DeferrerBuilder{} + [&]()
 Defer statement that will mtdefer execution until the scope is left, at which point the code will run Execution will happen regardless of whether there was an error.
 

Typedefs

using Environ = const char **
 Environment variable typedef.
 
typedef float f32
 Alias for 32-bit floats.
 
typedef double f64
 Alias for 64-bit floats.
 
typedef long double f80
 Alias for 80-bit floats.
 
typedef int8_t i8
 Alias for 8-bit ints.
 
typedef int16_t i16
 Alias for 16-bit ints.
 
typedef int32_t i32
 Alias for 32-bit ints.
 
typedef int64_t i64
 Alias for 64-bit ints.
 
typedef uint8_t u8
 Alias for 8-bit unsigned ints.
 
typedef uint16_t u16
 Alias for 16-bit unsigned ints.
 
typedef uint32_t u32
 Alias for 32-bit unsigned ints.
 
typedef uint64_t u64
 Alias for 64-bit unsigned ints.
 
typedef uintptr_t uptr
 Alias for ints the same size as a pointer.
 
typedef wchar_t wchar
 Alias for ints the same size as a wide character.
 
typedef int ThreeWayCompare
 

Enumerations

enum class  mtcore::CollectionAddNoAllocationError { mtcore::CollectionAddNoAllocationError::NO_ROOM }
 Errors when adding elements to collections when no allocation is allowed. More...
 

Functions

template<class... Ts>
 mtcore::overload (Ts...) -> overload< Ts... >
 

Macro Definition Documentation

◆ DEFER

#define DEFER ( LINE)
Value:
DEFER_(LINE)
#define DEFER_(LINE)

Definition at line 340 of file core/mtcore/core.hpp.

◆ DEFER_

#define DEFER_ ( LINE)
Value:
zz_defer##LINE

Definition at line 339 of file core/mtcore/core.hpp.

◆ MTCORE_CORE_HPP

#define MTCORE_CORE_HPP

Definition at line 32 of file core/mtcore/core.hpp.

◆ mtcore_warn

#define mtcore_warn ( ...)
Value:
fprintf(stderr, \
"\nWARNING!\n\t" \
"MESSAGE: %s\n\t" \
"WHERE: %s:%d\n", \
#__VA_ARGS__, __FILE__, __LINE__); \
(void) fflush(stderr);

Prints a warning message and stacktrace in debug builds Does nothing in release builds`.

Definition at line 271 of file core/mtcore/core.hpp.

271#define mtcore_warn(...) \
272 fprintf(stderr, \
273 "\nWARNING!\n\t" \
274 "MESSAGE: %s\n\t" \
275 "WHERE: %s:%d\n", \
276 #__VA_ARGS__, __FILE__, __LINE__); \
277 (void) fflush(stderr);

◆ mtcore_warn_trace

#define mtcore_warn_trace ( ...)
Value:
mt_print_cur_stacktrace("\nWARNING!\n\t" \
"MESSAGE: %s\n\t" \
"WHERE: %s:%d\n", \
#__VA_ARGS__, __FILE__, __LINE__);
#define mt_print_cur_stacktrace(...)
Prints the current stack trace with an optional message.

Prints a warning message in debug builds Does nothing in release builds`.

Definition at line 262 of file core/mtcore/core.hpp.

262#define mtcore_warn_trace(...) \
263 mt_print_cur_stacktrace("\nWARNING!\n\t" \
264 "MESSAGE: %s\n\t" \
265 "WHERE: %s:%d\n", \
266 #__VA_ARGS__, __FILE__, __LINE__);

◆ not_implemented

#define not_implemented ( )
Value:
unreachable("NOT IMPLEMENTED")
#define unreachable(...)
Marks code as unreachable.

Stub for code that's not implemented Will crash the program if reached in debug mode Will stop compilation if in release mode.

Definition at line 180 of file core/mtcore/core.hpp.

◆ print_debug

#define print_debug ( fmt,
... )
Value:
(void) fprintf(stderr, "\nDEBUG AT %s:%d! " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)

Prints a debug message when in debug mode.

Does nothing in release mode

Parameters
fmtC Format string for printing a debug message

Definition at line 199 of file core/mtcore/core.hpp.

Typedef Documentation

◆ Environ

using Environ = const char **

Environment variable typedef.

Definition at line 51 of file core/mtcore/core.hpp.

◆ ThreeWayCompare

typedef int ThreeWayCompare

Definition at line 137 of file core/mtcore/core.hpp.