FreeRTOS 匈牙利表示法
FreeRTOS Hungarian Notation
我是 RTOS 和 C 编程的完全新手,我仍然在习惯 C 的良好做法。所以我打开了一个使用 FreeRTOS 的项目,我注意到 OS 文件使用匈牙利表示法。我知道一点符号,但在 FreeRTOS.h
文件中遇到了一些新的 "standards",它们是:
#ifndef configASSERT
#define configASSERT( x )
#define configASSERT_DEFINED 0
#else
#define configASSERT_DEFINED 1
#endif
在下面,
#ifndef INCLUDE_xTaskGetSchedulerState
#define INCLUDE_xTaskGetSchedulerState 0
#endif
#ifndef INCLUDE_xTaskGetCurrentTaskHandle
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#endif
我见过这个 x - 如 xTaskGetCurrentTaskHandle - 无处不在。此外,v、pd 和类似的变量名称,如所讨论的 header 的第 728
行:
#if configENABLE_BACKWARD_COMPATIBILITY == 1
#define eTaskStateGet eTaskGetState
#define portTickType TickType_t
#define xTaskHandle TaskHandle_t
#define xQueueHandle QueueHandle_t
#define xSemaphoreHandle SemaphoreHandle_t
#define xQueueSetHandle QueueSetHandle_t
#define xQueueSetMemberHandle QueueSetMemberHandle_t
#define xTimeOutType TimeOut_t
#define xMemoryRegion MemoryRegion_t
#define xTaskParameters TaskParameters_t
#define xTaskStatusType TaskStatus_t
#define xTimerHandle TimerHandle_t
#define xCoRoutineHandle CoRoutineHandle_t
#define pdTASK_HOOK_CODE TaskHookFunction_t
#define portTICK_RATE_MS portTICK_PERIOD_MS
/* Backward compatibility within the scheduler code only - these definitions
are not really required but are included for completeness. */
#define tmrTIMER_CALLBACK TimerCallbackFunction_t
#define pdTASK_CODE TaskFunction_t
#define xListItem ListItem_t
#define xList List_t
我到处搜索 "initials" 代表什么,但仍然无法弄清楚。
所以,如果有人能帮助我理解这一点,或者能给我指路之类的,我将不胜感激。
正在查看the man
Naming Conventions
The RTOS kernel and demo application source code use the following conventions:
Variables
Variables of type uint32_t
are prefixed ul, where the 'u' denotes unsigned
and the 'l' denotes long
.
Variables of type uint16_t
are prefixed us, where the 'u' denotes 'unsigned' and the 's' denotes short
.
Variables of type uint8_t
are prefixed uc, where the 'u' denotes 'unsigned' and the 'c' denotes char
.
Variables of non stdint types are prefixed x. Examples include BaseType_t
and TickType_t
, which are portable layer defined typedefs for the natural or most efficient type for the architecture and the type used to hold the RTOS tick count respectively.
Unsigned
variables of non stdint types have an additional prefix u. For example variables of type UBaseType_t
(unsigned BaseType_t
) are prefixed ux.
Variables of type size_t
are also prefixed x.
Enumerated variables are prefixed e
Pointers have an additional prefixed p, for example a pointer to a uint16_t
will have prefix pus.
In line with MISRA guides, unqualified standard char types are only permitted to hold ASCII characters
and are prefixed c.
In line with MISRA guides, variables of type char *
are only permitted to hold pointers to ASCII strings
and are prefixed pc.
强调我的
Functions
File scope static (private) functions are prefixed with prv.
API functions are prefixed with their return type, as per the convention defined for variables, with the addition of the prefix v for void
.
API function names start with the name of the file in which they are defined. For example vTaskDelete
is defined in tasks.c, and has a void
return type.
强调我的
Macros
Macros are pre-fixed with the file in which they are defined. The pre-fix is lower case. For example, configUSE_PREEMPTION
is defined in FreeRTOSConfig.h.
Other than the pre-fix, macros are written in all upper case, and use an underscore to separate words.
强调我的
我是 RTOS 和 C 编程的完全新手,我仍然在习惯 C 的良好做法。所以我打开了一个使用 FreeRTOS 的项目,我注意到 OS 文件使用匈牙利表示法。我知道一点符号,但在 FreeRTOS.h
文件中遇到了一些新的 "standards",它们是:
#ifndef configASSERT
#define configASSERT( x )
#define configASSERT_DEFINED 0
#else
#define configASSERT_DEFINED 1
#endif
在下面,
#ifndef INCLUDE_xTaskGetSchedulerState
#define INCLUDE_xTaskGetSchedulerState 0
#endif
#ifndef INCLUDE_xTaskGetCurrentTaskHandle
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#endif
我见过这个 x - 如 xTaskGetCurrentTaskHandle - 无处不在。此外,v、pd 和类似的变量名称,如所讨论的 header 的第 728
行:
#if configENABLE_BACKWARD_COMPATIBILITY == 1
#define eTaskStateGet eTaskGetState
#define portTickType TickType_t
#define xTaskHandle TaskHandle_t
#define xQueueHandle QueueHandle_t
#define xSemaphoreHandle SemaphoreHandle_t
#define xQueueSetHandle QueueSetHandle_t
#define xQueueSetMemberHandle QueueSetMemberHandle_t
#define xTimeOutType TimeOut_t
#define xMemoryRegion MemoryRegion_t
#define xTaskParameters TaskParameters_t
#define xTaskStatusType TaskStatus_t
#define xTimerHandle TimerHandle_t
#define xCoRoutineHandle CoRoutineHandle_t
#define pdTASK_HOOK_CODE TaskHookFunction_t
#define portTICK_RATE_MS portTICK_PERIOD_MS
/* Backward compatibility within the scheduler code only - these definitions
are not really required but are included for completeness. */
#define tmrTIMER_CALLBACK TimerCallbackFunction_t
#define pdTASK_CODE TaskFunction_t
#define xListItem ListItem_t
#define xList List_t
我到处搜索 "initials" 代表什么,但仍然无法弄清楚。
所以,如果有人能帮助我理解这一点,或者能给我指路之类的,我将不胜感激。
正在查看the man
Naming Conventions
The RTOS kernel and demo application source code use the following conventions:
Variables
Variables of type
uint32_t
are prefixed ul, where the 'u' denotesunsigned
and the 'l' denoteslong
.Variables of type
uint16_t
are prefixed us, where the 'u' denotes 'unsigned' and the 's' denotesshort
.Variables of type
uint8_t
are prefixed uc, where the 'u' denotes 'unsigned' and the 'c' denoteschar
.Variables of non stdint types are prefixed x. Examples include
BaseType_t
andTickType_t
, which are portable layer defined typedefs for the natural or most efficient type for the architecture and the type used to hold the RTOS tick count respectively.
Unsigned
variables of non stdint types have an additional prefix u. For example variables of typeUBaseType_t
(unsigned BaseType_t
) are prefixed ux.Variables of type
size_t
are also prefixed x.Enumerated variables are prefixed e
Pointers have an additional prefixed p, for example a pointer to a
uint16_t
will have prefix pus.In line with MISRA guides, unqualified standard char types are only permitted to hold
ASCII characters
and are prefixed c.In line with MISRA guides, variables of type
char *
are only permitted to hold pointers toASCII strings
and are prefixed pc.
强调我的
Functions
File scope static (private) functions are prefixed with prv.
API functions are prefixed with their return type, as per the convention defined for variables, with the addition of the prefix v for
void
.API function names start with the name of the file in which they are defined. For example
vTaskDelete
is defined in tasks.c, and has avoid
return type.
强调我的
Macros
Macros are pre-fixed with the file in which they are defined. The pre-fix is lower case. For example,
configUSE_PREEMPTION
is defined in FreeRTOSConfig.h.Other than the pre-fix, macros are written in all upper case, and use an underscore to separate words.
强调我的