/*------------------------------------------------------------------------*/
/*                                                                        */
/*  Copyright (c) 2008 by MESA Imaging SA,                                */
/*                     http://www.mesa-imaging.ch                         */
/*------------------------------------------------------------------------*/
// $Author$
//    $URL$
//    $Rev$
//   $Date$
/*------------------------------------------------------------------------*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#define _USE_MATH_DEFINES
#define WIN32_LEAN_AND_MEAN    // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>

#include <stdio.h>
//<stdarg.h>
#ifndef _countof
  #define _countof(array) (sizeof(array)/sizeof(array[0]))
#endif
#define SAFE_FREE(p)       { if(p) { delete (p);     (p)=0; } }

#ifdef __cplusplus
extern "C" {
#endif
void logPrintf(const char* fmt, ...);
#ifdef __cplusplus
}
#endif


HINSTANCE AfxGetInstanceHandle();
inline BOOL AfxRegisterClass(WNDCLASS* lpWndClass){return(::RegisterClass(lpWndClass)?TRUE:FALSE);}

#ifdef _DEBUG
inline void TRACE(const char* fmt,...)
{
  char buf[4096];
  size_t len=0;
  size_t ofs=len;
  va_list marker;
  va_start( marker, fmt);
  len+=_vsnprintf(&buf[len], _countof(buf)-len, fmt, marker);
  OutputDebugString(buf);
}
#define ASSERT(code) if(!(code)){MessageBox(0,"code "#code"failed","__LINE__ :" __FILE__,MB_ICONHAND|MB_OK);DebugBreak();}
#else
#define ASSERT(f)          ((void)0)
#define VERIFY(f)          ((void)(f))
#define ASSERT_VALID(pOb)  ((void)0)
#define DEBUG_ONLY(f)      ((void)0)
#define TRACE              __noop
#define TRACE0(sz)
#define TRACE1(sz, p1)
#define TRACE2(sz, p1, p2)
#define TRACE3(sz, p1, p2, p3)
#endif
