Skip to content

Commit

Permalink
Avoid use of iostream
Browse files Browse the repository at this point in the history
Profiling indicates that include of iostream is a performance issue
  • Loading branch information
magnesj committed Mar 11, 2024
1 parent 725bd71 commit 3f84249
Showing 1 changed file with 10 additions and 58 deletions.
68 changes: 10 additions & 58 deletions Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafAssert.h
Original file line number Diff line number Diff line change
@@ -1,62 +1,14 @@

#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(); \
} \
#include <cstdio>

#define CAF_ASSERT( expr ) \
do \
{ \
if ( !( expr ) ) /* NOLINT */ \
{ \
std::printf( "%s : %i : CAF_ASSERT( %s ) failed\n", __FILE__, __LINE__, #expr ); \
std::abort(); \
} \
} while ( false )
#endif

0 comments on commit 3f84249

Please sign in to comment.