{"id":264336,"date":"2015-08-26T16:26:02","date_gmt":"2015-08-26T12:26:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=264336"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=264336","title":{"rendered":"\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 unit-\u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438"},"content":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ec6\/584\/f50\/ec6584f5014b4e4d901e14c70090a604.png\" align=\"right\"\/>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/240565\/\">\u0435\u0441\u0442\u044c<\/a> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <a href=\"http:\/\/habrahabr.ru\/post\/252439\/\">\u0441\u0442\u0430\u0442\u0435\u0439<\/a> \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/123344\/\">\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/a> \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438. \u042f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u043a\u0440\u0438\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0443 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u2014 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <a href=\"http:\/\/embox.github.io\/\">Embox<\/a>. \u041f\u0430\u0440\u0443 \u0440\u0430\u0437 \u043c\u044b \u0443\u0436\u0435 \u0441\u0441\u044b\u043b\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043d\u0435\u0433\u043e \u043d\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/embox\/blog\/239387\/\">\u0425\u0430\u0431\u0440\u0435<\/a>.<\/p>\n<p>  \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434\u043a\u0430\u0442! \u041d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e: \u0442\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u044f\u043d\u043e\u043a \u0438\u0437 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u00ab\u043b\u0438\u043d\u043a\u0435\u0440\u0441\u043a\u043e\u0439\u00bb \u043c\u0430\u0433\u0438\u0438.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b<\/h3>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043c\u0441\u044f \u0432 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u043a\u0443 \u0432\u043e\u043f\u0440\u043e\u0441\u0430. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0432 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0432\u0441\u0435\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u044c, \u0430 \u044d\u0442\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e.<br \/>  \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043e \u0432\u044b\u0437\u043e\u0432\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0443 \u043c\u0435\u043d\u044f \u0441\u0440\u0430\u0437\u0443 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043c\u044b\u0441\u043b\u0438 \u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439. \u0422\u043e \u0435\u0441\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0437\u044f\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0442\u0438\u043f\u0430 \u044d\u0442\u043e\u0439:  <\/p>\n<pre><code>void test_func_1(void) { } void test_func_2(void) { }  int main(void){     int i;     void (*all_tests[])(void) = {test_func_1, test_func_2};      for(i = 0; i &lt; sizeof(all_tests)\/sizeof(all_tests[0]); i ++) {         all_tests[i]();     }     return 0; } <\/code><\/pre>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u0432 \u0433\u043b\u0430\u0437\u0430 \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u044d\u0442\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e. \u0420\u0430\u0437\u043c\u044b\u0448\u043b\u044f\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0445\u043e\u0442\u0435\u043b\u043a\u0443:  <\/p>\n<blockquote><p>\u041f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0442\u043e\u0439 \u0438\u043b\u0438 \u0438\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0442\u043e\u043c\u0443 \u0438\u043b\u0438 \u0438\u043d\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443. <\/p><\/blockquote>\n<p>  \u0422\u0430\u043a\u043e\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0432 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0434 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c. \u042d\u0442\u043e \u043c\u043e\u0433\u043b\u043e \u0431\u044b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code>&lt;type&gt; arr[]; &lt;type&gt; a(array(arr)); &lt;type&gt; b(array(arr)); <\/code><\/pre>\n<p>  \u0418\u043b\u0438, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0432 gcc, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e __attribute__   <\/p>\n<pre><code>&lt;type&gt; arr[]; &lt;type&gt; a __attribute__(array_member(arr))); &lt;type&gt; b __attribute__(array_member(arr))); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438 \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u044d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0435, \u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438 \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440. \u0417\u043d\u0430\u0447\u0438\u0442, \u0435\u0441\u043b\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0443, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043b\u043e\u0436\u0438\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u044d\u0442\u0438\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>  \u0417\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440, \u0430 \u043b\u0438\u043d\u043a\u0435\u0440, \u0438 \u0432 \u043b\u0438\u043d\u043a\u0435\u0440-\u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445 \u0443\u043a\u0430\u0437\u0432\u044b\u0430\u0435\u0442\u0441\u044f, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u0418\u0437 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u044d\u0442\u0438\u0445 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043b\u0438\u043d\u043a\u0435\u0440 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0441\u0435\u043a\u0446\u0438\u044f\u043c, \u0438 \u0435\u0441\u043b\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u044d\u0442\u043e \u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u043f\u043e \u0441\u0443\u0442\u0438, \u0438 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043a-\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043a\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432, \u043c\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0417\u043d\u0430\u0447\u0438\u0442, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432. \u0410 \u0435\u0449\u0451 \u043b\u0443\u0447\u0448\u0435 \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430.<br \/>  \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e:  <\/p>\n<pre><code>&lt;type&gt; arr[] __attribute__((section(\u201carray_spread.arr\u201d))) = {}; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0442\u043a\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0435\u043a\u0446\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u0438\u0437 \u043b\u0438\u043d\u043a\u0435\u0440\u0430. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043b\u0438\u043d\u043a\u0435\u0440 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 SORT(\u201csection_name\u201d), \u043b\u0438\u043d\u043a\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 \u0432 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0438\u043c\u0432\u043e\u043b \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043d\u0430 \u043d\u0430\u0447\u0430\u043b\u043e \u0441\u0435\u043a\u0446\u0438\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u044f \u043f\u043e\u0434\u0441\u0435\u043a\u0446\u0438\u0438 \u043b\u0435\u043a\u0441\u0438\u043a\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438 \u0448\u043b\u043e \u0440\u0430\u043d\u044c\u0448\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0438\u043f\u0438\u0441\u0430\u0442\u044c \u201c0_head\u201d \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0430 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u2014 \u201c1_body\u201d. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u201c0\u201d \u0438 \u201c1\u201d, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0441\u0442\u0430\u043b \u0431\u044b \u043c\u0435\u043d\u0435\u0435 \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c.<\/p>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code>&lt;type&gt; arr[] __attribute__((section(\u201carray_spread.arr_0_head.rodata\u201d))) = {}; <\/code><\/pre>\n<p>  \u0421\u0430\u043c \u043b\u0438\u043d\u043a\u0435\u0440 \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code>SECTIONS {     .rodata.array_spread : {         *(SORT(.array_spread.*.rodata))     } } INSERT AFTER .rodata; <\/code><\/pre>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043b\u044e\u0447\u0430 gcc -T<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0442\u0443 \u0438\u043b\u0438 \u0438\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e, \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442:  <\/p>\n<pre><code>&lt;type&gt; a __attribute__((section(\u201carray_spread.arr_1_body.rodata\u201d))); <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430? \u0415\u0441\u043b\u0438 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0440\u0430\u043b\u0438 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445 \u0438 \u0434\u0435\u043b\u0438\u043b\u0438 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0435 \u0441\u0435\u043a\u0446\u0438\u0438. \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435, \u043a\u0430\u043a \u0438 \u0441 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u043c\u0435\u0442\u043a\u0443 \u0432 \u043a\u043e\u043d\u0435\u0446, \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u043f\u043e\u043c\u043d\u044f \u043e\u0431 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043d\u043e\u0439 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435.<br \/>  \u0418\u0442\u0430\u043a, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code>&lt;type&gt; arr_tail[] __attribute__((section(\u201carray_spread.arr_9_tail.rodata\u201d))) = {}; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code>#include &lt;stddef.h&gt; #include &lt;stdio.h&gt;  void test_func_1(void) {     printf(&quot;test 1\\n&quot;); } void test_func_2(void) {     printf(&quot;test 2\\n&quot;); }  void (*all_tests_item_1)(void) __attribute__((section(&quot;.array_spread.all_tests_1_body.rodata&quot;))) = test_func_1; void (*all_tests_item_2)(void) __attribute__((section(&quot;.array_spread.all_tests_1_body.rodata&quot;))) = test_func_2; void (*all_tests[])(void) __attribute__((section(&quot;.array_spread.all_tests_0_head.rodata&quot;))) = {}; void (*all_tests__tail[])(void) __attribute__((section(&quot;.array_spread.all_tests_9_tail.rodata&quot;))) = {};  int main(void){     int i;      printf(&quot;%zu tests start\\n&quot;, (size_t)(all_tests__tail - all_tests));      for(i = 0; i &lt; (size_t)(all_tests__tail - all_tests); i ++) {         all_tests[i]();     }     return 0; } <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043b\u0438\u043d\u043a\u0435\u0440-\u0441\u043a\u0440\u0438\u043f\u0442, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0447\u0442\u043e \u0438 \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438. \u041d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u043d\u043e \u0438 \u043c\u0430\u0441\u0441\u0438\u0432, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043b\u0438\u043d\u043a\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0430\u0434\u0438\u0438 \u0441\u0431\u043e\u0440\u043a\u0438, \u0441\u043e\u0431\u0438\u0440\u0430\u044f \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u043e\u0434\u0438\u043d, \u0438 \u044d\u0442\u043e \u043f\u043e\u0440\u043e\u0439 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e.<\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043b\u0438\u043d\u043a\u0435\u0440 \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0442\u0438\u043f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0432 \u0441\u0435\u043a\u0446\u0438\u044e, \u0438 \u0435\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432, \u0442\u043e \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u0430\u043c\u043e\u043c\u0443 \u0441\u0435\u0431\u0435 \u0437\u043b\u043e\u0431\u043d\u044b\u043c \u0411\u0443\u0440\u0430\u0442\u0438\u043d\u043e. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438.<\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u0435\u043d \u0432 \u043f\u043b\u0430\u043d\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442\u044c \u0441\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u0432\u0441\u044e \u043c\u0430\u0433\u0438\u044e \u0432 \u043c\u0430\u043a\u0440\u043e\u0441\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043c \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c \u0438 \u0432\u0432\u0435\u0434\u0451\u043c \u043f\u0430\u0440\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0432\u043e\u0434\u044f\u0442 \u0438\u043c\u0435\u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432, \u0441\u0435\u043a\u0446\u0438\u0439 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<br \/>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u043a\u0446\u0438\u0439:  <\/p>\n<pre><code>#define __ARRAY_SPREAD_SECTION(array_nm, order_tag) \\     &quot;.array_spread.&quot; #array_nm order_tag &quot;.rodata,\\&quot;a\\&quot;,%progbits;#&quot; <\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e (\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043a\u0443 \u043a\u043e\u043d\u0446\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430)  <\/p>\n<pre><code>#define __ARRAY_SPREAD_PRIVATE(array_nm, private_nm) \\     __array_spread__##array_nm##__##private_nm <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043c\u0430\u043a\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0432\u043e\u0434\u0438\u0442 \u043c\u0430\u0441\u0441\u0438\u0432.  <\/p>\n<pre><code>#define ARRAY_SPREAD_DEF(element_type, name) \\         element_type volatile const name[] __attribute__ ((used,        \\         \/* Some versions of GCC do not take into an account section     \\          * attribute if it appears after the definition. *\/             \\             section(__ARRAY_SPREAD_SECTION(name, &quot;0_head&quot;)))) =         \\             { \/* Empty anchor to the array head. *\/ };                  \\         element_type volatile const __ARRAY_SPREAD_PRIVATE(name,tail)[] \\         __attribute__ ((used,                                           \\         \/* Some versions of GCC do not take into an account section     \\          * attribute if it appears after the definition. *\/             \\             section(__ARRAY_SPREAD_SECTION(name, &quot;9_tail&quot;)))) =         \\             { \/* Empty anchor at the very end of the array. *\/ } <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435 \u043a\u043e\u0434, \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u044b\u0439 \u0432 \u043c\u0430\u043a\u0440\u043e\u0441.<br \/>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0432\u0432\u043e\u0434\u0438\u043c \u043c\u0435\u0442\u043a\u0443 \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u2014 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0435\u043a\u0446\u0438\u044e \u201c0_head\u201d. \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0432\u0432\u043e\u0434\u0438\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0435\u043a\u0446\u0438\u044e \u201c9_tail\u201d, \u044d\u0442\u043e \u0443\u0436\u0435 \u043a\u043e\u043d\u0435\u0446 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0414\u043b\u044f \u043c\u0435\u0442\u043a\u0438 \u043a\u043e\u043d\u0446\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u0445\u0438\u0442\u0440\u043e\u0435 \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0438\u043c\u044f, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u0443\u0436\u0435 \u0432\u0432\u0435\u0434\u0435\u043d \u043c\u0430\u043a\u0440\u043e\u0441 __ARRAY_SPREAD_PRIVATE. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0451! \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e \u0438 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0438\u043c \u043a\u0430\u043a \u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0432\u0435\u0434\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439:  <\/p>\n<pre><code>#define ARRAY_SPREAD_ADD(name, item)                                       \\     static typeof(name[0]) name ## __element[]  \\         __attribute__ ((used,                                               \\                 section(__ARRAY_SPREAD_SECTION(name, &quot;1_body&quot;)))) = { item } <\/code><\/pre>\n<p>  \u0422\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0438 \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0435\u043a\u0446\u0438\u044e. \u041e\u0442\u043b\u0438\u0447\u0438\u0435\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u044f \u043f\u043e\u0434\u0441\u0435\u043a\u0446\u0438\u0438 \u201c1_body\u201d \u0438 \u0442\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430. \u041a\u0441\u0442\u0430\u0442\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043b\u0451\u0433\u043a\u043e\u0439 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0435 \u0431\u0443\u0434\u0443 \u0435\u0451 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c. \u0414\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0443 \u0432 <a href=\"https:\/\/github.com\/embox\/embox\">\u043d\u0430\u0448\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>.<\/p>\n<p>  \u0423 \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0435\u0441\u043b\u0438 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0441 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u043d\u043e, \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u0435\u0441\u044c, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c __LINE__ \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0432\u0432\u0435\u0434\u0451\u043c \u043f\u0430\u0440\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432.<br \/>  \u041c\u0430\u043a\u0440\u043e\u0441 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u0442 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code>#define MACRO_CONCAT(m1, m2) __MACRO_CONCAT(m1, m2) #define __MACRO_CONCAT(m1, m2) m1 ## m2 <\/code><\/pre>\n<p>  \u041c\u0430\u043a\u0440\u043e\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043a \u0441\u0438\u043c\u0432\u043e\u043b\u0443 _at_line_ \u0438 \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code>#define MACRO_GUARD(symbol) __MACRO_GUARD(symbol) #define __MACRO_GUARD(symbol) MACRO_CONCAT(symbol ## _at_line_, __LINE__) <\/code><\/pre>\n<p>  \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043d\u0430\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430, \u0442\u043e\u0447\u043d\u0435\u0435, \u043d\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435, \u043d\u043e \u043e\u043e\u043e\u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u043e\u0435 \ud83d\ude42  <\/p>\n<pre><code>#define __ARRAY_SPREAD_GUARD(array_nm) \\     MACRO_GUARD(__ARRAY_SPREAD_PRIVATE(array_nm, element)) <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<pre><code>#define ARRAY_SPREAD_ADD(name, item)                                       \\     static typeof(name[0]) __ARRAY_SPREAD_GUARD(name)[]  \\         __attribute__ ((used,                                               \\                 section(__ARRAY_SPREAD_SECTION(name, &quot;1_body&quot;)))) = { item } <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043d\u0443\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441-\u043c\u0430\u0440\u043a\u0435\u0440 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u0432\u044b\u0447\u0435\u0441\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u043c\u0430\u0440\u043a\u0435\u0440 \u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043a\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430 \u043a\u0430\u043a \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430.  <\/p>\n<pre><code>#define ARRAY_SPREAD_SIZE(array_name) \\ ((size_t) (__ARRAY_SPREAD_PRIVATE(array_name, tail) - array_name)) <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0430\u0445\u0430\u0440\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043c\u0430\u043a\u0440\u043e\u0441\u0430 foreach   <\/p>\n<pre><code>#define array_spread_foreach(element, array) \\ for (typeof(element) volatile const *_ptr = (array),         \\ _end = _ptr + (ARRAY_SPREAD_SIZE(array));       \\ (_ptr &lt; _end) && (((element) = *_ptr) || 1); ++_ptr) <\/code><\/pre>\n<h3>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 unit-\u0442\u0435\u0441\u0442\u043e\u0432<\/h3>\n<p>  \u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a unit-\u0442\u0435\u0441\u0442\u0430\u043c. \u0423 \u043d\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u044d\u0442\u0430\u043b\u043e\u043d\u043d\u044b\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c \u0434\u043b\u044f unit-\u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Google_C%2B%2B_Testing_Framework\">googletest<\/a>. \u0427\u0442\u043e \u0432 \u043d\u0451\u043c \u0432\u0430\u0436\u043d\u043e:  <\/p>\n<ul>\n<li>\u041f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432<\/li>\n<li>\u041f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432<\/li>\n<li>\u041f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0435\u0434- \u0438 \u043f\u043e\u0441\u0442- \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043a\u0430\u043a \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432<\/li>\n<li>\u041f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u043e\u0432<\/li>\n<\/ul>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435. \u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 \u044d\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430.  <\/p>\n<pre><code>ARRAY_SPREAD_DEF(test_routine_t,all_tests);  static int test_func_1(void) {     return 0; } ARRAY_SPREAD_ADD(all_tests, test_func_1);  static int test_func_2(void) {     return 0; } ARRAY_SPREAD_ADD(all_tests, test_func_2); <\/code><\/pre>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0437\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code>array_spread_foreach(test, all_tests) {         if (test()) {             printf(&quot;error in test 0x%zu\\n&quot;, (uintptr_t)test);             return 0;         }         printf(&quot;.&quot;);     }     printf(&quot;OK\\n&quot;); <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0440\u0438\u043c\u0435\u0440 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0451\u043d, \u043d\u043e \u0443\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u043e\u0448\u0438\u0431\u043a\u0430, \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e. \u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u043e\u043c\u0443\u0434\u0440\u0438\u0442\u044c \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0440\u0430\u0437 \u0443\u0436 \u043c\u044b \u043f\u043e-\u0436\u0435\u0441\u0442\u043a\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043b\u0438\u043d\u043a\u0435\u0440, \u043d\u043e \u0435\u0449\u0451 \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434:  <\/p>\n<pre><code>TEST_CASE(\u201ctest1 description\u201d) { }; <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0449\u0435 \u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0439 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u0447\u0435\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u044d\u0442\u043e\u0433\u043e, \u0432\u0432\u0435\u0434\u0451\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430. \u041a\u0440\u043e\u043c\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438 \u043f\u043e\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f:  <\/p>\n<pre><code>struct test_case_desc {     test_routine_t routine;     char desc[]; }; <\/code><\/pre>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0432\u044b\u0437\u043e\u0432 \u0432\u0441\u0435\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code>    printf(&quot;%zu tests start&quot;, ARRAY_SPREAD_SIZE(all_tests));      array_spread_foreach(test, all_tests) {         if (test-&gt;routine()) {             printf(&quot;error in test 0x%s\\n&quot;, test-&gt;desc);             return 0;         }         printf(&quot;.&quot;);     }     printf(&quot;OK\\n&quot;); <\/code><\/pre>\n<p>  \u0410 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0432\u0435\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0449\u0435 \u0440\u0430\u0437 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c __LINE__.<br \/>  \u0422\u043e\u0433\u0434\u0430 \u0442\u0435\u0441\u0442, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0442\u0435\u0441\u0442\u0430 \u043a\u0430\u043a test_## __LINE__, \u0430 \u0432\u0435\u0441\u044c \u043c\u0430\u043a\u0440\u043e\u0441 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:  <\/p>\n<pre><code>#define TEST_CASE(desc) \\     __TEST_CASE_NM(&quot;&quot; desc, MACRO_GUARD(__test_case_struct), \\                     MACRO_GUARD(__test_case))  #define __TEST_CASE_NM(_desc, test_struct, test_func) \\     static int test_func(void);                      \\     static struct test_case_desc test_struct = { \\             .routine = test_func, \\             .desc = _desc,         \\     };                             \\     ARRAY_SPREAD_ADD(all_tests, &test_struct); \\     static int test_func(void) <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u0412\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u0432\u0432\u0435\u0434\u0435\u043d \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u2014 TEST_SUITE.<\/p>\n<p>  \u041f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u043d\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442, \u0430 \u043d\u0430\u0431\u043e\u0440 \u0442\u0435\u0441\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b. \u0422\u0443\u0442 \u043c\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0435\u043c\u0441\u044f \u0441 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u043d\u0430\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0414\u043b\u0438\u043d\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0438 \u0431\u0435\u0437 \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u043c \u043a\u043e\u043d\u0446\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a.<\/p>\n<h3>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0441 \u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c<\/h3>\n<p>  \u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b. \u0427\u0442\u043e \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043c \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0437 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u043b\u0438, \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u043e\u0434\u0441\u0435\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u043c \u043f\u043e\u0441\u043b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043c\u0430\u0440\u043a\u0435\u0440\u043e\u043c \u043a\u043e\u043d\u0446\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u2014 \u201c8_term\u201d.<br \/>  \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430:  <\/p>\n<pre><code>#define ARRAY_SPREAD_DEF(element_type, name) \\         ARRAY_SPREAD_TERM_DEF(element_type, name, \/* empty *\/)  #define ARRAY_SPREAD_TERM_DEF(element_type, name, _term) \\         element_type volatile const name[] __attribute__ ((used,        \\         \/* Some versions of GCC do not take into an account section     \\          * attribute if it appears after the definition. *\/             \\             section(__ARRAY_SPREAD_SECTION(name, &quot;0_head&quot;)))) =         \\             { \/* Empty anchor to the array head. *\/ };                  \\         element_type volatile const __ARRAY_SPREAD_PRIVATE(name,term)[] \\         __attribute__ ((used,                                           \\         \/* Some versions of GCC do not take into an account section     \\          * attribute if it appears after the definition. *\/             \\             section(__ARRAY_SPREAD_SECTION(name, &quot;8_term&quot;)))) =         \\             { _term };                                                    \\         element_type volatile const __ARRAY_SPREAD_PRIVATE(name,tail)[] \\         __attribute__ ((used,                                           \\         \/* Some versions of GCC do not take into an account section     \\          * attribute if it appears after the definition. *\/             \\             section(__ARRAY_SPREAD_SECTION(name, &quot;9_tail&quot;)))) =         \\             { \/* Empty anchor at the very end of the array. *\/ } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0430\u043a\u0440\u043e\u0441 foreach() \u0434\u043b\u044f \u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u043b\u0451\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432  <\/p>\n<pre><code>#define array_spread_nullterm_foreach(element, array) \\     __array_spread_nullterm_foreach_nm(element, array,  \\             MACRO_GUARD(__ptr))  #define __array_spread_nullterm_foreach_nm(element, array, _ptr) \\     for (typeof(element) volatile const *_ptr = (array);         \\             ((element) = *_ptr); ++_ptr)  <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041d\u0430\u0431\u043e\u0440\u044b \u0442\u0435\u0441\u0442\u043e\u0432<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u043d\u0430\u0431\u043e\u0440\u0430\u043c \u0442\u0435\u0441\u0442\u043e\u0432.<br \/>  \u041e\u043d\u0438 \u0442\u043e\u0436\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0432\u0435\u0434\u0451\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432:  <\/p>\n<pre><code>struct test_suite_desc {     const struct test_case_desc *volatile const *test_cases;     char desc[]; }; <\/code><\/pre>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438 \u0434\u0435\u043b\u0430, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0435\u0441\u0442\u043e\u0432.<br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0432\u0435\u0434\u0451\u043c \u043c\u0430\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432.  <\/p>\n<pre><code>#define TEST_SUITE(_desc) \\     ARRAY_SPREAD_TERM_DEF(static const struct test_case_desc *, \\             __TEST_CASES_ARRAY, NULL \/* *\/);                         \\     static struct test_suite_desc test_suite = {                  \\                     .test_cases = __TEST_CASES_ARRAY,                \\                     .desc = &quot;&quot;_desc,                             \\             };                                                   \\     ARRAY_SPREAD_ADD(all_tests, &test_suite) <\/code><\/pre>\n<p>  \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u0421 \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0432\u044b\u0448\u043b\u0430 \u043d\u0435\u0443\u0432\u044f\u0437\u043a\u0430 \u2014 \u0438\u043c\u044f \u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c, \u0432\u0435\u0434\u044c \u043e\u043d\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c, \u0445\u043e\u0442\u044c \u043c\u044b \u0438 \u043f\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u043b\u0438 \u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0412 \u0441\u0432\u043e\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"http:\/\/habrahabr.ru\/company\/embox\/blog\/144935\/\">\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0431\u043e\u0440\u043a\u0438<\/a>, \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441 \u0435\u0433\u043e \u043f\u043e\u043b\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c. \u0421 \u0445\u043e\u0434\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u043c\u044f \u0435\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438.  <\/p>\n<pre><code>#define __TEST_CASES_ARRAY test_case_array_1 TEST_SUITE(&quot;first test suite&quot;); <\/code><\/pre>\n<p>  \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0435\u043a\u0441\u0442\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e.<br \/>  \u041a\u0440\u043e\u043c\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430, \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u044d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432.<\/p>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u043a\u0440\u043e\u0441 \u0434\u043b\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442-\u043a\u0435\u0439\u0441\u0430:  <\/p>\n<pre><code>#define TEST_CASE(desc) \\     __TEST_CASE_NM(&quot;&quot; desc, MACRO_GUARD(__test_case_struct), \\                     MACRO_GUARD(__test_case))  #define __TEST_CASE_NM(_desc, test_struct, test_func)  \\     static int test_func(void);                        \\     static struct test_case_desc test_struct = {       \\             .routine = test_func,                      \\             .desc = _desc,                             \\     };                                                 \\     ARRAY_SPREAD_ADD(__TEST_CASES_ARRAY, &test_struct); \\     static int test_func(void) <\/code><\/pre>\n<p>  \u041f\u043e \u0441\u0443\u0442\u0438, \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0441\u0441\u0438\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0430\u0448 \u0442\u0435\u0441\u0442.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432:  <\/p>\n<pre><code>    array_spread_foreach(test_suite, all_tests) {         printf(&quot;%s&quot;, test_suite-&gt;desc);         array_spread_nullterm_foreach(test_case, test_suite-&gt;test_cases) {             if (test_case-&gt;routine()) {                 printf(&quot;error in test 0x%s\\n&quot;, test_case-&gt;desc);                 return 0;             }             printf(&quot;.&quot;);         }         printf(&quot;OK\\n&quot;);     } <\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043d\u0435\u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432, \u043d\u043e \u044f \u0445\u043e\u0447\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u0430\u044f. \u0415\u0441\u043b\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u0443\u0436\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<br \/>  \u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/735\/49a\/4b2\/73549a4b2c554171bcc336e54ca12cba.png\"\/><br \/>  \u041a\u043e\u0434 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043b\u0435\u0436\u0438\u0442 \u0443 \u043d\u0430\u0441 \u0432 <a href=\"https:\/\/github.com\/embox\/emtest\/pull\/1\">\u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a>. \u041c\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u043b\u0438, \u0447\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u043b\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0443 <a href=\"http:\/\/embox.github.io\/\">\u043d\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/a>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0441\u0442\u0430\u043b\u0438 \u0435\u0433\u043e \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c. \u041d\u0443 \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u044e, \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0443\u044e.<\/p>\n<p>  P.S. \u0410\u0432\u0442\u043e\u0440\u043e\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0438\u0434\u0435\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f  <a href=\"http:\/\/habrahabr.ru\/users\/abusalimov\/\" class=\"user_link\">abusalimov<\/a>.     \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/265461\/\"> http:\/\/habrahabr.ru\/post\/265461\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ec6\/584\/f50\/ec6584f5014b4e4d901e14c70090a604.png\" align=\"right\"\/>\u041d\u0430 \u0425\u0430\u0431\u0440\u0435 \u0443\u0436\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/240565\/\">\u0435\u0441\u0442\u044c<\/a> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <a href=\"http:\/\/habrahabr.ru\/post\/252439\/\">\u0441\u0442\u0430\u0442\u0435\u0439<\/a> \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/123344\/\">\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u0441\u0442\u044b<\/a> \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 \u0421\u0438. \u042f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u043a\u0440\u0438\u0442\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u043b\u0438\u0448\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0443 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u2014 \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <a href=\"http:\/\/embox.github.io\/\">Embox<\/a>. \u041f\u0430\u0440\u0443 \u0440\u0430\u0437 \u043c\u044b \u0443\u0436\u0435 \u0441\u0441\u044b\u043b\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u043d\u0435\u0433\u043e \u043d\u0430 <a href=\"http:\/\/habrahabr.ru\/company\/embox\/blog\/239387\/\">\u0425\u0430\u0431\u0440\u0435<\/a>.<\/p>\n<p>  \u041a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043f\u0440\u043e\u0448\u0443 \u043f\u043e\u0434\u043a\u0430\u0442! \u041d\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e: \u0442\u0430\u043c \u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u044f\u043d\u043e\u043a \u0438\u0437 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432 \u0438 \u00ab\u043b\u0438\u043d\u043a\u0435\u0440\u0441\u043a\u043e\u0439\u00bb \u043c\u0430\u0433\u0438\u0438.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-264336","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/264336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=264336"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/264336\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=264336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=264336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=264336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}