コンパイルアラームのwarning:function****could be declared with attribute'norereturn'および_attribute__(noreturn))プロパティ


1、MDKを使用してプログラムを作成する場合、一部の関数に戻り値がない場合、または関数戻り文が実行されない場合、コンパイラはこの関数をnoreturn属性として宣言するよう求めます.そうしないと、次のwarningと報告されます.
main.c(11): warning: function 'vTaskCode' could be declared with attribute 'noreturn' [-Wmissing-noreturn]

2、このwarningの消去方法はvTaskCode関数を宣言する時、__を加えることである.attribute__((noreturn))、具体的には以下の通りです.
static void vTaskCode(void *pvParameter); // warning

static void vTaskCode(void *pvParameter)__attribute__((noreturn));//no warning

3、_についてattribute__(noreturn)の説明
(1)This attribute tells the compiler that the function won't ever return, and this can be used to suppress errors about code paths not being reached. The C library functions abort() and exit() are both declared with this attribute.
extern void exit(int)   __attribute__((noreturn));
extern void abort(void) __attribute__((noreturn));

(2)A few standard library functions, such as abort and exit, cannot return. GCC knows this automatically. Some programs define their own functions that never return. You can declare them noreturn to tell the compiler this fact. For example:
void Test_No_Return () __attribute__ ((noreturn));