참고 : http://www.gamedev.net/page/resources/_/technical/general-programming/assert-verify-and-trace-for-non-mfc-appl-r1846

 

 

디버깅 시 편리한 TRACE, ASSERT 를 C++에서도 사용해 보자 ! 

 

첨부파일의 debug.h 와 debug.cpp를 해당 프로젝트에 추가 ! 

 

<debug.h>

 

// file debug.h
#ifndef __DEBUG_H__
#define __DEBUG_H__
#ifdef _DEBUG
void _trace(char *fmt, ...);
#define ASSERT(x) {if(!(x)) _asm{int 0x03}}
#define VERIFY(x) {if(!(x)) _asm{int 0x03}}
#else
#define ASSERT(x)
#define VERIFY(x) x
#endif
#ifdef _DEBUG
#define TRACE _trace
#else
inline void _trace(LPCTSTR fmt, ...) { }
#define TRACE  1 ? (void)0 : _trace
#endif
#endif // __DEBUG_H__

 

<debug.cpp>

 

//file debug.cpp
#ifdef _DEBUG
#include <stdio.h>
#include <stdarg.h>
#include <windows.h>
void _trace(char *fmt, ...)
{
char out[1024];
 va_list body;
 va_start(body, fmt);
 vsprintf(out, fmt, body);
 va_end(body);
 OutputDebugString(out);
}
#endif


'Programmer의 텅빈 공간 > C/C++' 카테고리의 다른 글

visual studio 단축키 정리  (0) 2015.08.04
singleton  (0) 2014.05.06
메모리 풀을 왜 사용해야 하는가 ?  (0) 2014.05.06
메모리 풀이란 ?  (0) 2014.05.06
메모리 누수체크  (0) 2014.05.06

+ Recent posts