
本帖最后由 any012 于 2016-12-30 11:23 编辑 用cube生成了个freertos的工程,默认任务是通过这个函数创建的: MX_FREERTOS_Init(); 这个函数里,有两句: osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); 第一句中的osThreadDef是个宏定义: #define osThreadDef(name, thread, priority, instances, stacksz) \ const osThreadDef_t os_thread_def_##name = \ { #name, (thread), (priority), (instances), (stacksz) } 其中的 ##name,这是什么用法? os ThreadDef_t是个结构体: typedef struct os_thread_def { char *name; ///< Thread name os_pthread pthread; ///< start address of thread function osPriority tpriority; ///< initial thread priority uint32_t instances; ///< maximum number of instances of that thread function uint32_t stacksize; ///< stack size requirements in bytes; 0 is default stack size } osThreadDef_t; ------------------------------------------------------------ 以下图片是QQ群里一位朋友分享的。 ![]() |
##表示连接,例long n=CONN(123,456),n=123456。怎么样我的回答满意不
评分
查看全部评分
举例说:
#define Com(x,y) x##y
int n = Com(123,456); 结果就是n=123456;
char* str = Com("asdf", "adf")结果就是 str = "asdfadf";
你给出的宏
#是预编译的象征有了这个编译器就知道他是在预编译前需要做的事
如包含文件
#include< >
#define N 100//在编译前将N全部替换为100
点评
评分
查看全部评分