Add ox_assert to ox/std

This commit is contained in:
Gary Talent 2018-03-05 23:07:04 -06:00
parent 85c747ad1a
commit b616d9c0f2
3 changed files with 38 additions and 0 deletions

View File

@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.8)
add_library(
OxStd
assert.cpp
memops.cpp
random.cpp
strops.cpp
@ -16,6 +17,7 @@ set_property(
install(
FILES
assert.hpp
bitops.hpp
byteswap.hpp
memops.hpp

19
deps/ox/src/ox/std/assert.cpp vendored Normal file
View File

@ -0,0 +1,19 @@
/*
* Copyright 2015 - 2018 gtalent2@gmail.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#if defined(OX_USE_STDLIB)
#include <cstdlib>
#include <iostream>
#endif
void oxAssert(const char *file, int line, bool pass, const char *msg) {
if (!pass) {
std::cerr << '(' << file << ':' << line << "): " << msg << std::endl;
std::abort();
}
}

17
deps/ox/src/ox/std/assert.hpp vendored Normal file
View File

@ -0,0 +1,17 @@
/*
* Copyright 2015 - 2018 gtalent2@gmail.com
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
void oxAssert(const char *file, int line, bool pass, const char *msg);
#ifdef NDEBUG
#define ox_assert(pass, msg) oxAssert(__FILE__, __LINE__, pass, msg)
#else
#define ox_assert(pass, msg)
#endif