Changeset 34 in libcf for trunk/include/cf_debug.h


Ignore:
Timestamp:
02/05/13 11:26:59 (11 years ago)
Author:
cheese
Message:

#1 add example code for doxygen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_debug.h

    r30 r34  
    1111 * 환경에 적합하도록 사용자가 구성한 컨텍스트를 이용하여 사용할 수도 있음 <br />
    1212 * (단, 콜스택의 푸시/팝은 컨텍스트를 이용해야만 사용 가능)
     13 *
     14 * @section 샘플코드
     15 * @code
     16
     17#include "cf_debug.h"
     18
     19CF_Debug_Ctx gDebugCtx;
     20
     21void callee (void) {
     22    CF_Debug_CallStack callstack;
     23   
     24    CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
     25    CF_DEBUG_CALLSTACK_POP (gDebugCtx, &callstack);
     26}
     27
     28int main (void) {
     29    int fd = 0;
     30    gDebugCtx = CF_Debug_CreateCtx ();
     31
     32    CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
     33
     34    CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to stderr\n");
     35
     36    fd = CF_File_Create ("debug.txt");
     37    if (fd < 0) {
     38        CF_DEBUG_PRINT (stderr, "error ...\n");
     39        // error
     40    }
     41    CF_Debug_SetOutputFD (gDebugCtx, fd);
     42
     43    CF_DEBUG_TRACE (gDebugCtx, "print trace message with context to debug.txt\n");
     44
     45    CF_DEBUG_CALLSTACK_POP (gDebugCtx, NULL);
     46
     47    CF_Debug_DestroyCtx (gDebugCtx);
     48
     49    return 0;
     50}
     51
     52 * @endcode
    1353 */
    1454#ifndef __CF_DEBUG_H__
     
    1959#include <stdio.h>
    2060
    21 /** 잘못된 컨텍스트 오류 */
    2261#define CF_ERROR_DEBUG_INVALID_CTX          CF_ERROR_DEBUG - 1
    23 
    24 /** 디버그 메시지 출력을 위한 파일 포인터 설정 오류 */
    2562#define CF_ERROR_DEBUG_SET_OUTPUT_FD        CF_ERROR_DEBUG - 2
    26 
    27 /** 콜스택 푸시 오류 */
    2863#define CF_ERROR_DEBUG_PUSH_CALLSTACK       CF_ERROR_DEBUG - 3
    29 
    30 /** 콜스택 팝 오류 */
    3164#define CF_ERROR_DEBUG_POP_CALLSTACK        CF_ERROR_DEBUG - 4
    3265
Note: See TracChangeset for help on using the changeset viewer.