ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib.hpp File Reference

Description:


This header file is part of the ALib C++ Library .

© 2013-2024 A-Worx GmbH, Germany. Published under Boost Software License.

This header does not belong to a module of ALib , but is included in any ALib Distribution . Its purposes are:

  • To identify given ALib Compiler Symbols related to module selection and enable corresponding symbols (that may be not given) of dependent modules.
  • Provide functions Bootstrap and Shutdown which select the right bootstrapping and shutdown methods, depending on the ALib Distribution .
Note
This header is not shown in inclusion graphs of this documentation, as it is always included directly or indirectly.

Definition in file alib.hpp.

#include <assert.h>
Include dependency graph for alib.hpp:

Go to the source code of this file.

Classes

struct  CompilationFlagMeaningsEntry
 
struct  TCompilationFlags
 

Namespaces

namespace  alib
 
namespace  alib::lang
 

Macros

#define ALIB_DOCUMENTATION_URL   "https://alib.dev/"
 defined(ALIB_DOX)
 
ALib Version And Feature Verification

Macros used to verify that the ALib binary used has the right version is compiled with the same feature set as the current compilation unit. For this, version and feature flags are compiled statically into the library. The macros are used internally, respectively 'automatically'. Hence, they need not to be used directly clients of the library.

#define ALIB_ASSERT_MODULE(modulename)
 
#define ALIB_REVISION   1
 
#define ALIB_VERSION   2402
 
ALib Module Selection

This group of symbols determine the availability of different ALib Modules of the ALib Distribution used. The symbols are defined in header alib/alib.hpp which always is and has to be the first ALib header file included (directly or indirectly). If none of the symbols is passed to the compiler, this header file will define all to 1, hence will include all modules a distribution.

If a symbol is given as 1, all corresponding symbols of dependent modules are also defined to 1, even if one had explicitly given as 0, which is considered a contradicting input.

#define ALIB_ALOX   1
 
#define ALIB_BITBUFFER   1
 
#define ALIB_BOXING   1
 
#define ALIB_CAMP   1
 
#define ALIB_CHARACTERS   1
 
#define ALIB_CLI   1
 
#define ALIB_CONFIGURATION   1
 
#define ALIB_ENUMS   1
 
#define ALIB_EXPRESSIONS   1
 
#define ALIB_FILES   1
 
#define ALIB_MONOMEM   1
 
#define ALIB_SINGLETONS   1
 
#define ALIB_STRINGS   1
 
#define ALIB_THREADS   1
 
#define ALIB_TIME   1
 
Code Selection

The macros listed here include or prune code, dependent on different preprocessor symbols. They are mainly given to avoid #if/#else/#endif statements for small code pieces.

#define ALIB_CPP_23(...)
 
#define ALIB_CPP_BEFORE_23(...)   __VA_ARGS__
 
#define ALIB_DBG(...)   __VA_ARGS__
 
#define ALIB_IF_ALOX(...)   __VA_ARGS__
 
#define ALIB_IF_BITBUFFER(...)   __VA_ARGS__
 
#define ALIB_IF_BOXING(...)   __VA_ARGS__
 
#define ALIB_IF_CAMP(...)   __VA_ARGS__
 
#define ALIB_IF_CHARACTERS(...)   __VA_ARGS__
 
#define ALIB_IF_CLI(...)   __VA_ARGS__
 
#define ALIB_IF_CONFIGURATION(...)   __VA_ARGS__
 
#define ALIB_IF_ENUMS(...)   __VA_ARGS__
 
#define ALIB_IF_EXPRESSIONS(...)   __VA_ARGS__
 
#define ALIB_IF_FILES(...)   __VA_ARGS__
 
#define ALIB_IF_MONOMEM(...)   __VA_ARGS__
 
#define ALIB_IF_SINGLETONS(...)   __VA_ARGS__
 
#define ALIB_IF_STRINGS(...)   __VA_ARGS__
 
#define ALIB_IF_THREADS(...)   __VA_ARGS__
 
#define ALIB_IF_TIME(...)   __VA_ARGS__
 
#define ALIB_IFN_ALOX(...)
 
#define ALIB_IFN_BITBUFFER(...)
 
#define ALIB_IFN_BOXING(...)
 
#define ALIB_IFN_CAMP(...)
 
#define ALIB_IFN_CHARACTERS(...)
 
#define ALIB_IFN_CLI(...)
 
#define ALIB_IFN_CONFIGURATION(...)
 
#define ALIB_IFN_ENUMS(...)
 
#define ALIB_IFN_EXPRESSIONS(...)
 
#define ALIB_IFN_FILES(...)
 
#define ALIB_IFN_MONOMEM(...)
 
#define ALIB_IFN_SINGLETONS(...)
 
#define ALIB_IFN_STRINGS(...)
 
#define ALIB_IFN_THREADS(...)
 
#define ALIB_IFN_TIME(...)
 
#define ALIB_REL(...)
 
#define ALIB_REL_DBG(releaseCode, ...)   __VA_ARGS__
 
C/C++ Language And Linkage Macros

The macros listed here are supporting C++ compilation and linking control and language specific utilities.

#define ALIB_API   __declspec(dllexport)
 
#define ALIB_ASSERT_GLOBAL_NAMESPACE
 
#define ALIB_CALLER   __FILE__, __LINE__, __func__
 
#define ALIB_CALLER_NULLED   ALIB_CALLER
 
#define ALIB_CALLER_PRUNED   ALIB_CALLER
 
#define ALIB_FORCE_INLINE   __forceinline
 
#define ALIB_NO_RETURN   [[ noreturn ]]
 
#define ALIB_SIZEOF_WCHAR_T   4
 
ALib Module Characters Feature Selection

#define ALIB_CHARACTERS_SIZEOF_WCHAR   ALIB_SIZEOF_WCHAR_T
 
#define ALIB_CHARACTERS_WIDE   1
 
C/C++ Compiler Warning Control

ALib sources are designed to be compiled on different compilers using the highest possible compiler warning levels available. In some situations, some warnings need to be temporarily disabled. The following macros do this in a compiler agnostic way.

#define ALIB_FALLTHROUGH   [[clang::fallthrough]];
 
#define ALIB_WARNINGS_ALLOW_BITWISE_SWITCH
 
#define ALIB_WARNINGS_ALLOW_MACRO_REDEFINITION
 
#define ALIB_WARNINGS_ALLOW_NULL_POINTER_PASSING    _Pragma("clang diagnostic push") \
 
#define ALIB_WARNINGS_ALLOW_SHIFT_COUNT_OVERFLOW
 
#define ALIB_WARNINGS_ALLOW_SPARSE_ENUM_SWITCH
 
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
 
#define ALIB_WARNINGS_ALLOW_UNSAFE_FUNCTION_OR_VARIABLE
 
#define ALIB_WARNINGS_IGNORE_DOCS
 
#define ALIB_WARNINGS_IGNORE_FUNCTION_TEMPLATE
 
#define ALIB_WARNINGS_IGNORE_INTEGER_OVERFLOW
 
#define ALIB_WARNINGS_IGNORE_INTEGRAL_CONSTANT_OVERFLOW    _Pragma("clang diagnostic push") \
 
#define ALIB_WARNINGS_IGNORE_NOTHING_RETURNED
 
#define ALIB_WARNINGS_IGNORE_RESERVED_IDENTIFIER
 
#define ALIB_WARNINGS_IGNORE_UNUSED_MACRO
 
#define ALIB_WARNINGS_IGNORE_UNUSED_PARAMETER
 
#define ALIB_WARNINGS_MACRO_NOT_USED_OFF
 
#define ALIB_WARNINGS_OVERLOAD_VIRTUAL_OFF
 
#define ALIB_WARNINGS_RESERVED_MACRO_NAME_OFF
 
#define ALIB_WARNINGS_RESTORE    _Pragma("clang diagnostic pop") \
 
#define ALIB_WARNINGS_UNINITIALIZED_OFF
 
C/C++ Preprocessor Helper Macros

The following macros are fundamental and building blocks for other macros.

#define ALIB_COMMA   ,
 
#define ALIB_COMMA_DBG   ,
 
#define ALIB_CONCAT(a, b)   a ## b
 
#define ALIB_EMPTY
 
#define ALIB_IDENTIFIER(prefix)
 
#define ALIB_NSTRINGIFY(a)
 
#define ALIB_STATIC_ASSERT(CondVariable, Cond, Message)
 
#define ALIB_STATIC_DENY(CondVariable, Cond, Message)
 
#define ALIB_STRINGIFY(a)
 
Debug Assertions, Warnings and Errors

The macros listed here are defined in two different versions, depending on the ALib distribution. With single ALib Modules that do not incorporate class alib::lang::Report and family, namespace function alib::lang::DbgSimpleALibMsg (and overloads) are used to write the messages. The default implementation of this message invokes assert(false) if the message is of error type.
There is a very simple "plug-in" concept in place that allows to redirect this method to a user defined one which may act differently.

If class report is included in the selected ALib distribution, two things happen:

  • the aforementioned plug-in is implemented and an ALib Report is generated inside the plug-in function.
  • The macros themselves are redefined to directly use the ALib Report facility. Such redefinition happens "in the middle" of header inclusion (as early as possible), with the effect that most classes of ALib are compiled using the simple version, but still use the mechanics of ALib Reports. Other parts of ALib classes, and of-course all user code, will have the more sophisticated, report-based versions of the macros in place. The huge advantage of them is, that those accept an arbitrary list of arguments which are boxed and passed to a formatter. This allows to easily compose detailed and formatted debug messages.

If also module ALox is compiled into the library, then a plug-in that uses ALox for the message output is used. See class ALoxReportWriter for more information.

#define ALIB_ASSERT(cond)   { if(!(cond)) ALIB_ERROR( "Assertion Failed" ); }
 
#define ALIB_ASSERT_ERROR(cond, ...)   { if(!(cond)) ALIB_ERROR( __VA_ARGS__ ); }
 
#define ALIB_ASSERT_MESSAGE(cond, ...)   { if(!(cond)) ALIB_MESSAGE( __VA_ARGS__ ); }
 
#define ALIB_ASSERT_RESULT_EQUALS( func, value)   { auto result= func; assert(result == value); ((void) result); }
 
#define ALIB_ASSERT_RESULT_GREATER_THAN(func, value)   { auto result= func; assert(result > value); ((void) result); }
 
#define ALIB_ASSERT_RESULT_LESS_THAN( func, value)   { auto result= func; assert(result < value); ((void) result); }
 
#define ALIB_ASSERT_RESULT_NOT_EQUALS( func, value)   { auto result= func; assert(result != value); ((void) result); }
 
#define ALIB_ASSERT_WARNING(cond, ...)   { if(!(cond)) ALIB_WARNING( __VA_ARGS__ ); }
 
#define ALIB_ERROR(...)   { alib::lang::DbgSimpleALibMsg( ALIB_CALLER_PRUNED, 0, __VA_ARGS__); }
 
#define ALIB_MESSAGE(...)   { alib::lang::DbgSimpleALibMsg( ALIB_CALLER_PRUNED, 2, __VA_ARGS__); }
 
#define ALIB_WARNING(...)   { alib::lang::DbgSimpleALibMsg( ALIB_CALLER_PRUNED, 1, __VA_ARGS__); }
 
General Preprocessor Symbols

The following general symbols (aka symbols not related to distinct ALib Modules ) may be passed to the compiler:

#define ALIB_AVOID_ANALYZER_WARNINGS   1
 

Functions

ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE void AssertALibVersionAndFlags (int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
 
ALIB_WARNINGS_RESTORE void Bootstrap (int alibVersion, int alibRevision, TCompilationFlags compilationFlags)
 
void DbgCheckSingleThreaded ()
 
ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, int type, const char *topic, const char *msg, const int intValue)
 
ALIB_API void DbgSimpleALibMsg (const char *file, int line, const char *method, int type, const char *topic, const char *msg1=nullptr, const char *msg2=nullptr, const char *msg3=nullptr, const char *msg4=nullptr, const char *msg5=nullptr)
 
void Shutdown ()
 

Macro Definition Documentation

◆ ALIB_DOCUMENTATION_URL

#define ALIB_DOCUMENTATION_URL   "https://alib.dev/"

defined(ALIB_DOX)

Definition at line 188 of file alib.hpp.