Work around weird unused errors with Mingw (#6075)

Summary:
From the reset of the code, it looks this this maybe can be unconditionally given the attribute? But I couldn't test with MSVC so I defensively put under CPP.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6075

Differential Revision: D18723749

fbshipit-source-id: 45fc8732c28dd29aab1644225d68f3c6f39bd69b
This commit is contained in:
John Ericson 2019-11-26 21:40:16 -08:00 committed by Facebook Github Bot
parent aa1857e2df
commit c16b087427
3 changed files with 18 additions and 3 deletions

View File

@ -1025,7 +1025,12 @@ Status WinRandomRWFile::Close() {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
/// WinMemoryMappedBufer /// WinMemoryMappedBufer
WinMemoryMappedBuffer::~WinMemoryMappedBuffer() { WinMemoryMappedBuffer::~WinMemoryMappedBuffer() {
BOOL ret = FALSE; BOOL ret
#if defined(_MSC_VER)
= FALSE;
#else
__attribute__((__unused__));
#endif
if (base_ != nullptr) { if (base_ != nullptr) {
ret = ::UnmapViewOfFile(base_); ret = ::UnmapViewOfFile(base_);
assert(ret); assert(ret);

View File

@ -138,7 +138,12 @@ void WindowsThread::join() {
"WaitForSingleObjectFailed: thread join"); "WaitForSingleObjectFailed: thread join");
} }
BOOL rc; BOOL rc
#if defined(_MSC_VER)
= FALSE;
#else
__attribute__((__unused__));
#endif
rc = CloseHandle(reinterpret_cast<HANDLE>(data_->handle_)); rc = CloseHandle(reinterpret_cast<HANDLE>(data_->handle_));
assert(rc != 0); assert(rc != 0);
data_->handle_ = 0; data_->handle_ = 0;

View File

@ -21,7 +21,12 @@ const char* Status::CopyState(const char* state) {
#ifdef OS_WIN #ifdef OS_WIN
const size_t cch = std::strlen(state) + 1; // +1 for the null terminator const size_t cch = std::strlen(state) + 1; // +1 for the null terminator
char* result = new char[cch]; char* result = new char[cch];
errno_t ret; errno_t ret
#if defined(_MSC_VER)
;
#else
__attribute__((__unused__));
#endif
ret = strncpy_s(result, cch, state, cch - 1); ret = strncpy_s(result, cch, state, cch - 1);
result[cch - 1] = '\0'; result[cch - 1] = '\0';
assert(ret == 0); assert(ret == 0);