AudRecordLib
Defines
macroutils.h File Reference

Defines a custom ASSERT macro and other useful macro stuff. More...

Go to the source code of this file.

Defines

#define CONCAT_INT(a, b)   a##b
#define CONCAT(a, b)   CONCAT_INT(a, b)
#define WSTRINGIFY_INT(a)   CONCAT(L, #a)
#define WSTRINGIFY(a)   WSTRINGIFY_INT(a)
#define STRINGIFY_INT(a)   #a
#define STRINGIFY(a)   STRINGIFY_INT(a)
#define DISABLE_CONST_COND()
#define END_DISABLE_CONST_COND()   __pragma(warning(pop))
#define CASSERT(expr)   static const char CONCAT(cassertTester, __COUNTER__) [(expr) ? 1 : -1]
#define ASSERT(expr)

Detailed Description

Defines a custom ASSERT macro and other useful macro stuff.


Define Documentation

#define ASSERT (   expr)
Value:
DISABLE_CONST_COND() \
        do \
        { \
                if(!(expr)) \
                { \
                        OutputDebugStringA( \
                        "Assertion Failed: " \
                        #expr \
                        "\nFile: " \
                        __FILE__ \
                        ", line " \
                        STRINGIFY(__LINE__) \
                        ", function \"" \
                        __FUNCTION__ \
                        "\".\n" \
                        ); \
                        DebugBreak(); \
                } \
        } \
        while(0); \
        END_DISABLE_CONST_COND()

If expr is false, it logs an error to the debugger text output. It then calls DebugBreak to stop the program on the line that failed the test. In non-debug builds, it does nothing.

#define CASSERT (   expr)    static const char CONCAT(cassertTester, __COUNTER__) [(expr) ? 1 : -1]

Causes a compile time error by trying to define an array of negative size is the expr evaluates to false.

#define CONCAT (   a,
 
)    CONCAT_INT(a, b)

Concatenates b to a by passing the arguments to CONCAT_INT() This is so any macro parameters are exapanded before the pasting takes place

#define CONCAT_INT (   a,
 
)    a##b

Internal macro that actually performs the concatenation of a and b with the token pasting operator

#define DISABLE_CONST_COND ( )
Value:
__pragma(warning(push)) \
        __pragma(warning(disable : 4127))

As the name suggests, the macro disables the 'conditional expression is constant' warning Primarily for use in asserts and other macros that test conditions

#define END_DISABLE_CONST_COND ( )    __pragma(warning(pop))

Restores the compilers warning state that was saved before the conditional warning was disabled by DISABLE_CONST_COND()

#define STRINGIFY (   a)    STRINGIFY_INT(a)

Turns a into a character string by putting it in speech marks. The argument is passed to STRINGIFY_INT so that a is expanded if it's a macro itself

#define STRINGIFY_INT (   a)    #a

Internal macro that actually turns a into a string This is simply done using the stringify (#) operator

#define WSTRINGIFY (   a)    WSTRINGIFY_INT(a)

Turns a into a wide character string by putting it in speech marks and prepending an L. The argument is passed to WSTRINGIFY_INT so that a is expanded if it's a macro itself

#define WSTRINGIFY_INT (   a)    CONCAT(L, #a)

Internal macro that actually turns a into a wide string This is achieved by passing an L and a narrow string of a to CONCAT so they are paasted together

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Defines