Silence delete compile warning in memory.h/cpp on Windows

pull/602/head
Bastiaan Olij 2021-08-28 14:59:09 +10:00
parent dd72ce151a
commit b07559882c
2 changed files with 27 additions and 0 deletions

View File

@ -44,6 +44,14 @@ _ALWAYS_INLINE_ void *operator new(size_t p_size, void *p_pointer, size_t check,
return p_pointer;
}
#ifdef _MSC_VER
// When compiling with VC++ 2017, the above declarations of placement new generate many irrelevant warnings (C4291).
// The purpose of the following definitions is to muffle these warnings, not to provide a usable implementation of placement delete.
void operator delete(void *p_mem, const char *p_description);
void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size));
void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description);
#endif
namespace godot {
class Memory {

View File

@ -51,3 +51,22 @@ void Memory::free_static(void *p_ptr) {
void *operator new(size_t p_size, const char *p_description) {
return godot::Memory::alloc_static(p_size);
}
using namespace godot;
#ifdef _MSC_VER
void operator delete(void *p_mem, const char *p_description) {
ERR_PRINT("Call to placement delete should not happen.");
CRASH_NOW();
}
void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) {
ERR_PRINT("Call to placement delete should not happen.");
CRASH_NOW();
}
void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) {
ERR_PRINT("Call to placement delete should not happen.");
CRASH_NOW();
}
#endif