qxLib
Macros
common.h File Reference
#include <qx/containers/string/string_setup.h>
#include <qx/meta/qualifiers.h>
#include <qx/macros/common.inl>

Go to the source code of this file.

Macros

#define QX_UNUSED(...)   ((void)sizeof(__VA_ARGS__))
 Suppress unused variable warnings. More...
 
#define QX_EMPTY_MACRO   static_assert(true)
 Placeholder for disabled macros. More...
 
#define QX_JOIN(symbol1, symbol2)   _QX_DO_JOIN(symbol1, symbol2)
 Concatenates two preprocessor tokens, performing macro expansion on them first.
 
#define QX_LINE   int(QX_JOIN(__LINE__, U))
 Same as LINE, but fixes some problems when using it in constexpr context.
 
#define QX_SHORT_FILE   qx::details::last_slash(QXT(__FILE__))
 Cuts full absolute path to the file name only ex: "C:\folder1\folder2\file.h" => "file.h".
 
#define QX_CONST_CAST_THIS()   const_cast<qx::switch_const_t<std::remove_pointer_t<decltype(this)>>*>(this)
 This macro is made for situations where you have a const method, and you need exactly the same method but non-const. More...
 
#define QX_CALL_BEFORE_MAIN   inline volatile qx::details::call_before_main_invoker QX_LINE_NAME(_stubCallBeforeMain)
 Calls this lambda before the main invocation. More...
 
#define QX_DISABLE_OPTIMIZATIONS()   _QX_DISABLE_OPTIMIZATIONS()
 Start a block with compiling optimisations disabled. Must be outside of functions and have an appropriate QX_ENABLE_OPTIMIZATIONS().
 
#define QX_ENABLE_OPTIMIZATIONS()   _QX_ENABLE_OPTIMIZATIONS()
 End a block with compiling optimisations disabled.
 
#define QX_FORCE_INLINE   _QX_FORCE_INLINE
 Make this function forcefully inlined (except for QX_DEBUG build)
 
#define QX_APPEND_VA_ARG_COUNT(prefix, ...)   _QX_APPEND_VA_ARG_COUNT(prefix, ##__VA_ARGS__)
 Add VA_ARGS count to the preprocessor prefix. More...
 
#define QX_VA_ARG_COUNT(...)   QX_APPEND_VA_ARG_COUNT(, ##__VA_ARGS__)
 Get number of va args. More...
 
#define QX_EXPAND(x)   x
 Forces an extra macro expansion step so that a macro result is fully resolved before being used as a function-like macro.
 

Detailed Description

Author
Khrapov
Date
17.06.2019

Definition in file common.h.

Macro Definition Documentation

◆ QX_APPEND_VA_ARG_COUNT

#define QX_APPEND_VA_ARG_COUNT (   prefix,
  ... 
)    _QX_APPEND_VA_ARG_COUNT(prefix, ##__VA_ARGS__)

Add VA_ARGS count to the preprocessor prefix.

It supports up to 32 arguments, ranging from 0 (empty parentheses).

Parameters
prefix- preprocessor prefix
...- va args to count
QX_APPEND_VA_ARG_COUNT(foo_, 1, 1, 1); // -> foo_3
#define QX_APPEND_VA_ARG_COUNT(prefix,...)
Add VA_ARGS count to the preprocessor prefix.
Definition: common.h:103

Definition at line 103 of file common.h.

◆ QX_CALL_BEFORE_MAIN

#define QX_CALL_BEFORE_MAIN   inline volatile qx::details::call_before_main_invoker QX_LINE_NAME(_stubCallBeforeMain)

Calls this lambda before the main invocation.

Note
This function must be in an object file, that is actually linked to your exe
{
};
#define QX_CALL_BEFORE_MAIN
Calls this lambda before the main invocation.
Definition: common.h:76

Definition at line 76 of file common.h.

◆ QX_CONST_CAST_THIS

#define QX_CONST_CAST_THIS ( )    const_cast<qx::switch_const_t<std::remove_pointer_t<decltype(this)>>*>(this)

This macro is made for situations where you have a const method, and you need exactly the same method but non-const.

Warning
You can also use it in vice versa situations, but be careful as it will break your const guarantees
int foo() const
{
// some complicated stuff
}
int foo()
{
}
#define QX_CONST_CAST_THIS()
This macro is made for situations where you have a const method, and you need exactly the same method...
Definition: common.h:63

Definition at line 63 of file common.h.

◆ QX_EMPTY_MACRO

#define QX_EMPTY_MACRO   static_assert(true)

Placeholder for disabled macros.

Has no effect and work correctly with "if else" You can use it in the end of a macro to enforce user to add ; after it

Definition at line 28 of file common.h.

◆ QX_UNUSED

#define QX_UNUSED (   ...)    ((void)sizeof(__VA_ARGS__))

Suppress unused variable warnings.

Parameters
...- one or more variables

Definition at line 20 of file common.h.

◆ QX_VA_ARG_COUNT

#define QX_VA_ARG_COUNT (   ...)    QX_APPEND_VA_ARG_COUNT(, ##__VA_ARGS__)

Get number of va args.

It supports up to 32 arguments, ranging from 0 (empty parentheses).

Parameters
...- va args to count
QX_VA_ARG_COUNT(1, 1, 1); // -> 3
#define QX_VA_ARG_COUNT(...)
Get number of va args.
Definition: common.h:113

Definition at line 113 of file common.h.