Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 28 Aug 2012
Offline Last Active Sep 23 2012 12:10 PM

#4974610 What does this algorithm do?

Posted by Coro on 29 August 2012 - 05:10 PM

Hey everyone

I was looking at a game engine to see how the different developers structure the code in their projects. I came across this algorithm but cannot figure out what it does exactly.

This algorithm is stored in a header file.

// Static compile-time assertion
namespace StaticAssert
template< bool > struct FAILED;
template<> struct FAILED< true > { };

#define ASSERT_STATIC( exp ) (StaticAssert::FAILED< (exp) != 0 >())

Can anyone explain what it does? "ASSERT_STATIC" is implemented in a cpp file. Here's the code:

// Check some platform-dependent assumptions
// Note: this function is never called but just wraps the compile time asserts
static void __ValidatePlatform__()
ASSERT_STATIC( sizeof( int64 ) == 8 );
ASSERT_STATIC( sizeof( int ) == 4 );
ASSERT_STATIC( sizeof( short ) == 2 );
ASSERT_STATIC( sizeof( char ) == 1 );

Thank you for reading!