svvitch
digital signage player
D:/vs_workspace/switch_sf/src/svvitch/Common.h
Go to the documentation of this file.
00001 #pragma once
00002 //
00003 // Common.h
00004 // 共通で使用するマクロや定数の定義
00005 //
00006 
00007 #include <windows.h>
00008 #include <stdio.h> //for sprintf
00009 
00010 typedef char                    Sint8;                              
00011 typedef short                   Sint16;                             
00012 typedef long                    Sint32;                             
00013 typedef __int64                 Sint64;                             
00014 typedef unsigned char           Uint8;                              
00015 typedef unsigned short          Uint16;                             
00016 typedef unsigned long           Uint32;                             
00017 typedef unsigned __int64        Uint64;                             
00018 typedef float                   Float;                              
00019 typedef float                   Float32;                            
00020 typedef double                  Float64;                            
00021 typedef bool                    Bool;                               
00022 
00023 #define toF(V)                  ((Float)(V))                                                                ///< Float型へのキャストマクロ
00024 #define toI(V)                  ((Sint32)(V))                                                               ///< Sint32型へのキャストマクロ
00025 #define F(V)                    toF(V)
00026 #define L(V)                    toI(V)
00027 
00028 #define PI                      (3.141592653589793238462643383279f)                                         ///< π
00029 #define PI2                     (6.283185307179586476925286766559f)                                         ///< 2π
00030 #define REV(V)                  toF(1.0f/toF(V))                                                            ///< 逆数算出マクロ
00031 
00032 // メモリの解放
00033 #define SAFE_DELETE(p)  { if(p) { delete (p);     (p)=NULL; } }
00034 
00035 // 参照カウンタのデクリメント
00036 #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
00037 
00038 // エラーの報告とアプリケーションの終了
00039 #define ERROR_EXIT() { int line = __LINE__; const char *file = __FILE__;¥
00040     char msg[_MAX_FNAME + _MAX_EXT + 256];¥
00041     char drive[_MAX_DRIVE];¥
00042     char dir[_MAX_DIR];¥
00043     char fname[_MAX_FNAME];¥
00044     char ext[_MAX_EXT];¥
00045     _splitpath(file, drive, dir, fname, ext);¥
00046     sprintf(msg, "何らかのエラーが発生したためアプリケーションを終了します¥r¥n"¥
00047         "ファイル : %s%s¥r¥n"¥
00048         "行番号 : %d", fname, ext, line);¥
00049     MessageBox(NULL, msg, "Error", MB_OK | MB_ICONEXCLAMATION);¥
00050     PostQuitMessage(1);¥
00051 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines