msvc: enable /Zc:preprocessor and make build compile cleanly

This commit is contained in:
Shawn Hoffman 2020-08-27 21:58:48 -07:00
parent 4db06bf85b
commit 969ea6e4f5
6 changed files with 13 additions and 57 deletions

View file

@ -32,39 +32,6 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
void SetEnableAlert(bool enable);
} // namespace Common
#if defined(_WIN32) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL == 1)
#define SuccessAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__)
#define PanicAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__)
#define PanicYesNo(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__)
#define AskYesNo(format, ...) Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__)
#define CriticalAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__)
// Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, __VA_ARGS__)
#define PanicAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Warning, format, __VA_ARGS__)
#define PanicYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Warning, format, __VA_ARGS__)
#define AskYesNoT(format, ...) \
Common::MsgAlert(true, Common::MsgType::Question, format, __VA_ARGS__)
#define CriticalAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, __VA_ARGS__)
#else
#define SuccessAlert(format, ...) \
Common::MsgAlert(false, Common::MsgType::Information, format, ##__VA_ARGS__)
@ -95,4 +62,3 @@ void SetEnableAlert(bool enable);
#define CriticalAlertT(format, ...) \
Common::MsgAlert(false, Common::MsgType::Critical, format, ##__VA_ARGS__)
#endif

View file

@ -15,12 +15,6 @@
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#define CHECK(cond, Message, ...) \
if (!(cond)) \
{ \
PanicAlert("%s failed in %s at line %d: " Message, __func__, __FILE__, __LINE__, __VA_ARGS__); \
}
namespace DX11
{
using Microsoft::WRL::ComPtr;

View file

@ -9,13 +9,6 @@
#include "Common/MsgHandler.h"
#include "VideoBackends/D3DCommon/Common.h"
#define CHECK(cond, Message, ...) \
if (!(cond)) \
{ \
PanicAlert(__FUNCTION__ " failed in %s at line %d: " Message, __FILE__, __LINE__, \
__VA_ARGS__); \
}
namespace DX12
{
using Microsoft::WRL::ComPtr;

View file

@ -12,6 +12,13 @@
#include "Common/CommonTypes.h"
#define CHECK(cond, Message, ...) \
if (!(cond)) \
{ \
PanicAlert("%s failed in %s at line %d: " Message, __func__, __FILE__, __LINE__, \
##__VA_ARGS__); \
}
struct IDXGIFactory;
enum class AbstractTextureFormat : u32;

View file

@ -20,11 +20,7 @@ constexpr u32 MAX_XFB_WIDTH = 720;
// that are next to each other in memory (TODO: handle that situation).
constexpr u32 MAX_XFB_HEIGHT = 576;
#if defined(_WIN32) && (!defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL == 1)
#define PRIM_LOG(...) DEBUG_LOG(VIDEO, __VA_ARGS__)
#else
#define PRIM_LOG(...) DEBUG_LOG(VIDEO, ##__VA_ARGS__)
#endif
// warning: mapping buffer should be disabled to use this
// #define LOG_VTX() DEBUG_LOG(VIDEO, "vtx: %f %f %f, ", ((float*)g_vertex_manager_write_ptr)[-3],

View file

@ -81,12 +81,8 @@
<LanguageStandard>stdcpplatest</LanguageStandard>
<!--Enable Standard Conformance-->
<ConformanceMode>true</ConformanceMode>
<!--Enforce some behaviors as standards-conformant when they don't default as such.
TODO: Enable /Zc:preprocessor. Note as of VS 16.7 and despite claims on msdn, the
new preprocessor has some notable bugs/regressions, and isn't warning-free when
used on WinSDK (<= 10.0.19041) headers.
-->
<AdditionalOptions>/Zc:externConstexpr,lambda,throwingNew /volatile:iso %(AdditionalOptions)</AdditionalOptions>
<!--Enforce some behaviors as standards-conformant when they don't default as such.-->
<AdditionalOptions>/Zc:externConstexpr,lambda,preprocessor,throwingNew /volatile:iso %(AdditionalOptions)</AdditionalOptions>
<!--Enable detailed debug info-->
<AdditionalOptions>/Zo %(AdditionalOptions)</AdditionalOptions>
<!--Treat sources as utf-8-->
@ -109,6 +105,10 @@
Currently jits use some annoying code patterns which makes this common
-->
<DisableSpecificWarnings>4245;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<!-- Temporarily disable warnings to enable /Zc:preprocessor compatibility with WinSDK headers.
5105 macro expansion producing 'defined' has undefined behavior
-->
<DisableSpecificWarnings>5105;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<!-- Enable some off-by-default warnings
4263 Non-virtual member function hides base class virtual function
4265 Class has virtual functions, but destructor is not virtual