Files
ResInsight/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAssert.h
Magne Sjaastad 21843820e6 Update clang-tidy.yml
* Make sure clang-tidy action use .clang-tidy config file
Use add-paths to instruct create-pull-request to a sub folder to avoid diff from Qt and vcpkg

* Use empty() in macro to avoid clang-tidy warning
* Add NOLINT to CAF_ASSERT
* Add NOLINT to cvfAssert
2023-10-03 09:04:08 +02:00

63 lines
2.4 KiB
C++

#pragma once
#include <cstdlib>
#include <iostream>
#define CAF_ASSERT( expr ) \
do \
{ \
if ( !( expr ) ) /* NOLINT */ \
{ \
std::cout << __FILE__ << ":" << __LINE__ << ": CAF_ASSERT(" << #expr << ") failed" << std::endl; \
std::abort(); \
} \
} while ( false )
#if 0 // Bits and pieces for reference to improve the assert
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4668 )
#include <windows.h>
#pragma warning( pop )
#endif
void openDebugWindow()
{
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4996 )
AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
#pragma warning( pop )
#endif
}
void assertAbort()
{
#ifdef _MSC_VER
#if ( _MSC_VER >= 1600 )
//if (::IsDebuggerPresent())
#endif
{
__debugbreak();
}
#endif
std::terminate();
}
#define ASSERT_TEST( expr ) \
do \
{ \
if ( !( expr ) ) \
{ \
std::cout << __FILE__ << ":" << __LINE__ << ": CAF_ASSERT(" << #expr << ") failed" << std::endl; \
assertAbort(); \
} \
} while ( false )
#endif