我是 RTOS 和 C 编程的新手,而且我仍在习惯 C 的良好实践。因此,我打开了一个使用 FreeRTOS 的项目,我注意到操作系统文件使用匈牙利表示法。我知道一点符号,但在文件中遇到了一些新的“标准” FreeRTOS.h
,它们是:
#ifndef configASSERT
#define configASSERT( x )
#define configASSERT_DEFINED 0
#else
#define configASSERT_DEFINED 1
#endif
Run Code Online (Sandbox Code Playgroud)
在那之下,
#ifndef INCLUDE_xTaskGetSchedulerState
#define INCLUDE_xTaskGetSchedulerState 0
#endif
#ifndef INCLUDE_xTaskGetCurrentTaskHandle
#define INCLUDE_xTaskGetCurrentTaskHandle 0
#endif
Run Code Online (Sandbox Code Playgroud)
我到处都看到过这个x - 就像x TaskGetCurrentTaskHandle一样。此外,v、pd和类似的变量名称,如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 …
Run Code Online (Sandbox Code Playgroud) 我正在深入研究C中的指针和字符串,我仍然习惯于一些概念.我试图实现该strchr()
函数的一个版本- 与string.h中的相同 - 用于研究目的,但基本的东西仍然不正确.
这是我的代码:
#include <stdio.h>
char* my_strchr(const char* str, int c){
if (str == NULL){
printf("STR is NULL. Finishing the program\n");
return NULL;
}
while (*str != '\0'){
if (*str == c){
return (char*) str;
}
str++;
}
return NULL;
}
int main(){
char *a = "Hello World!";
char *b;
char c;
printf("Type the character you want to find in the Hello World! string:\n");
scanf(" %c", &c);
b = my_strchr(a, c);
printf("Character found! %c\n", *b);
return …
Run Code Online (Sandbox Code Playgroud)