mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
0cced44142
Per https://en.cppreference.com/w/cpp/preprocessor/replace#.23_and_.23.23_operators the `##` behavior is a nonstandard extension; this extension seems to be supported by all compilers we care about, but IntelliSense in visual studio doesn't correctly handle it, resulting in false errors in the IDE (but not when compiling). Per https://en.cppreference.com/w/cpp/preprocessor/replace#Function-like_macros C++20 introduced a workaround, where `__VA_OPT__(, )` generates a comma if and only if `__VA_ARGS__` is non-empty. This PR replaces all occurrences, with the exception of Externals, DSPSpy (which is not likely to be edited in MSVC and does not target C++20 currently), and JitArm64_Integer.cpp (which uses `Function(__VA_ARGS__)`, and thus does not ever need a comma).
51 lines
3.5 KiB
C
51 lines
3.5 KiB
C
// Copyright 2015 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include "Common/Common.h"
|
|
#include "Common/CommonFuncs.h"
|
|
#include "Common/Logging/Log.h"
|
|
#include "Common/MsgHandler.h"
|
|
|
|
#define ASSERT_MSG(_t_, _a_, _fmt_, ...) \
|
|
do \
|
|
{ \
|
|
if (!(_a_)) \
|
|
{ \
|
|
if (!PanicYesNoFmtAssert(_t_, \
|
|
"An error occurred.\n\n" _fmt_ "\n\n" \
|
|
" Condition: {}\n File: {}\n Line: {}\n Function: {}\n\n" \
|
|
"Ignore and continue?", \
|
|
__VA_ARGS__ __VA_OPT__(, ) #_a_, __FILE__, __LINE__, __func__)) \
|
|
Crash(); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define DEBUG_ASSERT_MSG(_t_, _a_, _fmt_, ...) \
|
|
do \
|
|
{ \
|
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LogLevel::LDEBUG) \
|
|
ASSERT_MSG(_t_, _a_, _fmt_ __VA_OPT__(, ) __VA_ARGS__); \
|
|
} while (0)
|
|
|
|
#define ASSERT(_a_) \
|
|
do \
|
|
{ \
|
|
if (!(_a_)) \
|
|
{ \
|
|
if (!PanicYesNoFmt("An error occurred.\n\n" \
|
|
" Condition: {}\n File: {}\n Line: {}\n Function: {}\n\n" \
|
|
"Ignore and continue?", \
|
|
#_a_, __FILE__, __LINE__, __func__)) \
|
|
Crash(); \
|
|
} \
|
|
} while (0)
|
|
|
|
#define DEBUG_ASSERT(_a_) \
|
|
do \
|
|
{ \
|
|
if constexpr (Common::Log::MAX_LOGLEVEL >= Common::Log::LogLevel::LDEBUG) \
|
|
ASSERT(_a_); \
|
|
} while (0)
|