4/12/2015

Define 및 코딩스타일 정리

1. 기본 주석 스타일 정리

/*****************************************************************************************************
                                                                            
 * Author      : Lee,xxxxx                                                                         
 * Mailto      :                                                              
 * OS Name     : Linux                                                                                
 * OS Ver.     : x.x.x                                                                             
 * Writen date : 20xx/06/28                                                                           
 * API.ver     : 0.0.1                                                                                
 
 * Purpose     :   
 * Description :   
                   
*****************************************************************************************************/ 


2. struct & enum rules

 typedef struct _JitterInfo {
  u32  nTotalElmt;  //number
  u32 *pData;   //pointer
  u32  szTotalElmt;  //size
  JitterInfo symJitterInfo; //struct
  JitterInfo *psymJitter;  //struct pointer
 }JitterInfo;  //첫문자는 소문자 나머지는 대문자.

 typedef enum {
  EN_JITTER_NOTSET=0,  //EN Enum의 약자.
  EN_JITTER_FIRSTWORKING,
  EN_JITTER_WORKING,
  EN_JITTER_NOTWORK,
 }JitterStatus; //첫문자는 대문자 나머지는 소문자 

3. Functions rules & variables rules

 #define IN //input variables 
 #define OUT //output variables
 #define BO //return variables 

  //첫워드의 첫문자는 소문자, 두번째 첫워드부터는 대문자로 통일.
 audioJitterInit(int IN nArgs,int OUT  ) 
 {
  JitterInfo symJitter
  JitterInfo *psymJitter;
   
 } 

3. header file rules

 #ifndef _H323_JITTERS_H_
 #define _H323_JITTERS_H_

 #endif //_H323_JITTERS_H_ 

4. debug macro rules

 type 1
 #define H323_DL1             ON     /* be used, if function failed */  
 #define H323_DL2             OFF     /* be used, if this shows a consol function's informations */
 #define H323_DL3             OFF     /* be used, if you will testfy basic'src  */

 /********************************************/
 /*  Application Debugger MACRO              */
 /********************************************/

 /* H.323 Library debug */
 #if H323_DL1 // Fuction Error
  #define H323DL1(x,args...) printf("h323:%s:(%d) "x,__FUNCTION__,__LINE__,##args);
 #else 
  #define H323DL1(x,args...)
 #endif

 #if H323_DL2 // Function Information
  #define H323DL2(x,args...) printf("h323:%s:(%d) "x,__FUNCTION__,__LINE__,##args);
 #else 
  #define H323DL2(x,args...)
 #endif
 
 #if H323_DL3 // Only Test
  #define H323DL3(x,args...) printf("h323:%s:(%d) "x,__FUNCTION__,__LINE__,##args);
 #else 
  #define H323DL3(x,args...) 
 #endif

type 2
 #define DEBUG    1
 #undef DEBUG
 
 #ifdef DEBUG
  #define DBG(stuff...)        printk(KERN_DEBUG "dm320: " stuff)
 #else
  #define DBG(stuff...)        do{}while(0)
 #endif
 
 #define NEW_DEBUG
 
 #ifdef NEW_DEBUG
  #define N_DBG(stuff...)           printk(stuff)
 #else
  #define N_DBG(stuff...)           do{}while(0)
 #endif

 #ifdef VERBOSE
  #    define VDBG        DBG
 #else
  #    define VDBG(stuff...)    do{}while(0)
 #endif

 #ifdef PACKET_TRACE
  #    define PACKET        VDBG
 #else
  #    define PACKET(stuff...)    do{}while(0)
 #endif

 #define ERR(stuff...)       printk(KERN_ERR "dm320: " stuff)
 #define WARN(stuff...)      printk(KERN_WARNING "dm320: " stuff)
 #define INFO(stuff...)      printk(KERN_INFO "dm320: " stuff)




#define err(format, arg...)  printk(KERN_ERR     "bcm3510: " format "\n" , ## arg)
#undef info
#define info(format, arg...) printk(KERN_INFO    "bcm3510: " format "\n" , ## arg)
#undef warn
#define warn(format, arg...) printk(KERN_WARNING "bcm3510: " format "\n" , ## arg)


#define DEBUG(dbg, format, args...) \
  {if(DEBUG_##dbg) \
  printk(KERN_DEBUG "irnet: %s(): " format, __FUNCTION__ , ##args);}


 
H323DL3("Could not set sample rate (%d)\n", samplerate); 

댓글 없음 :