Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CodingGuidelines

Field Convention Example


Public scope (exported symbols)
Global Variable g_<type>_<ModuleName><VariableName> g_s32_osalState
Global Array ga_<type>_<ModuleName><VariableName> ga_s32_ipncMediaBuffer
Global Pointer gp_<type>_<ModuleName><VariableName> gp_ch_twitterDownloadFlag
Global double Pointer gpp_<type>_osal<VariableName> gpp_s8_osalDoublePointer
Global Variable of user pid_t g_s_epgAppPid
g_s_<ModuleName><VariableName>
defined data types size_t g_s_recCtrlContentDuration
Structure (type) S_<ModuleName><StructureName>_t S_youtubeClientObject_t
Structure member <type>_<memberName> s32_accessCount
Enumeration (type) E_<ModuleName><EnumerationName>_t E_galErrorCode_t
Enumeration (member) E_<MODULE_NAME>_<MEMBER_NAME> E_GAL_ERROR_NONE
Global Enum Variable g_e_<ModuleName><VariableName> g_e_galErrorCode
Macro <MODULE_NAME>_<MACRO_NAME> DVB_CTRL_PSI_SI_PAT_PID
File <ModuleName>_<FileName> mdsr_iptvTunerApi.h
Function <ModuleName>_<FunctionName> mdsr_iptvTunerOpen
Function Pointer gp_f_<ModuleName><FunctionPointerName> gp_f_ialRemoteEventCallback
Void Pointer gp_v_<ModuleName><PointerName> gp_v_osalFileName
Double Pointer gpp_<type>_<ModuleName><VariableName> gpp_s_youtubeClientObj
Array of pointers gap_<type>_<ModuleName><VariableName> gap_s_youtubeClientUrl
Public scope (internal symbols)
Structure (type) S_<functionality><StructureName>_t S_resourceUsage_t
Structure member <type>_<memberName> s32_accessCount
Enumeration (type) E_<functionality><EnumerationName>_t E_posixErrorCode_t
Enumeration member E_<FUNCTIONALITY>_<MEMBER_NAME> E_TRACE_MAX_NUM
Macro <FUNCTIONALITY>_<MACRO_NAME> TRACE_MAX_COUNT
Global Static function pointer sgp_f_<functionality><FunctionPointerName> sgp_f_memTrackerErrCallback
Global Static void pointer sgp_v_<functionality><SomePointerName> sgp_v_posixGenericPointer
Global Static variable sg_<type>_<VariableName> sg_u8_errorType
Global Static function <fileName><FunctionName> traceModulePrintApi
Private file <fileName> memoryTracker.c

Generic Guidelines
Define a structure only in header files
Define an enum only in header files
Use header guard _<HeaderFileName>_ in all the header files (Ex: _MDSR_IPTVTUNERAPI_H_)
Provide function headers for each function
Provide file header for each file
Try to initialize the variable while defining
Don't use Tabs. Assume 1 Tab = 4 spaces
Source code files should be in UNIX format
Make the header files re-usable in C++ environment (Use extern C)
Labels should be prefixed/suffixed with corresponding function names (Ex: _MDSR_IPTV_TUNER_OPEN_END)
Use OLSP_CHAR (char) for strings. Don't use OLSP_UINT8 or OLSP_SINT8

Page 1
Examples

Naming examples
Array of structures S_patInfo_t a_s_pat[10]
Array of pointers S_pmtInfo_t *ap_s_pmt[10]
Float OLSP_FLOAT32 f32_var
32-bit Signed Integer OLSP_SINT32 s32_cnt
32-bit Unsigned Integer OLSP_UINT32 u32_time
String OLSP_CHAR a_ch_name[32]

Structure Definition
typedef struct S_youtubeClientObjectTag
{
OLSP_SINT32 s32_streamId;
E_youtubeClientErrCode_t e_errorCode;
pthread_t s_monitorThreadId;
OLSP_CHAR a_ch_thumbailName[256];
} S_youtubeClientObject_t;

Enum Definition

typedef enum E_galErrorCodeTag


{
E_GAL_ERROR_NONE = 0,
E_GAL_ERROR_BUSY = -100,
E_GAL_ERROR_FONT_TYPE,
E_GAL_ERROR_INVALID_REQUEST
} E_galErrorCode_t;

Header File (fileMgrUtil.h)

/* TODO: Add Copy Right */


#ifndef _FILEMGRUTIL_H_
#define _FILEMGRUTIL_H_

/* ============================ System Includes =========================== */


// NONE

/* ============================= User Includes ============================ */


#include "osal_common_api.h"
#include "fileMgrApi.h"

#ifdef __cplusplus
extern "C" {
#endif

/* =========================== Macro definitions ========================== */


#define FILE_MGR_ONE_SEC_IN_MICRO_SEC (1000 * 1000)

/* ============================ Type definitions ========================== */


// NONE

/* ===================== Global variable declarations ===================== */


//NONE

/* ======================== Function declarations ========================= */


E_fileMgrErrorCode_t fileMgrGetCurTimeSinceEpochInMicroSec(OLSP_SINT64 *p_s64_curTimeInMicroSec);

#ifdef __cplusplus
} /* END: extern "C" */
#endif

#endif /* END: _FILEMGRUTIL_H_ */

Page 2

You might also like