{"id":262284,"date":"2015-07-26T03:32:02","date_gmt":"2015-07-25T23:32:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=262284"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=262284","title":{"rendered":"\u041f\u0441\u0435\u0432\u0434\u043e \u041e\u041e\u041f \u0432 C"},"content":{"rendered":"<p>     \t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e20\/31a\/29a\/e2031a29a85745fd93008156a409d840.jpg\" height=\"42\" width=\"42\"\/><br \/>  \u042f\u0437\u044b\u043a \u0421\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c. \u0418 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0435 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0438\u0436\u0435 \u044d\u0442\u043e \u043a\u043e\u0441\u0442\u044b\u043b\u0438 \u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b. <br \/>  \u041e\u041e\u041f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0442\u0440\u0438 \u0441\u0442\u043e\u043b\u043f\u0430: \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c. \u041d\u0438\u0436\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u044d\u0442\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0421. <br \/>  <a name=\"habracut\"><\/a><br \/>  <b>\u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f <\/b><br \/>  \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u0412 \u041e\u041e\u041f \u044f\u0437\u044b\u043a\u0430\u0445 \u043c\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430, \u0430 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043d\u0438\u043c \u043f\u0438\u0448\u0435\u043c \u0441\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0433\u0435\u0442\u0442\u0435\u0440\u044b. \u0414\u043b\u044f \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0421\u0438, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e static, \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u043f\u043e\u043c\u0438\u043c\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0432\u043e\u0438\u0445 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b) \u043e\u0434\u043d\u0438\u043c \u0444\u0430\u0439\u043b\u043e\u043c.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440:  <\/p>\n<pre><code>\/\/foo.c static void foo1 () {   puts(&quot;foo1&quot;); } void foo2 () {   puts(&quot;foo2&quot;); } \/\/main.c #include &lt;stdio.h&gt; int main() {   foo1();   foo2();   return 0; } <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443  <\/p>\n<pre><code>[main.c:(.text+0x1b): undefined reference to `foo1' collect2.exe: error: ld returned 1 exit status] <\/code><\/pre>\n<p>  \u0418\u043c\u0435\u044f \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c public \u0438 private \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u0430\u043c, \u0430 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: \u043e\u0434\u043d\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0430\u044f, \u0430 \u0432\u0442\u043e\u0440\u0430\u044f \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0443\u044e. \u0427\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0435, \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442.<\/p>\n<p>  \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0441 \u0441\u0435\u0442\u0442\u0435\u0440\u0430\u043c\u0438, \u0433\u0435\u0442\u0442\u0435\u0440\u0430\u043c\u0438 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c.  <\/p>\n<pre><code>\/\/point2d.h typedef struct point2D {   void *prvtPoint2D;   int (*getX) (struct point2D*);   void (*setX)(struct point2D*, int);  \/\/... } point2D; point2D* newPoint2D(); void deletePoint2D(point2D*); <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c.  <\/p>\n<pre><code>\/\/point2d.c #include &lt;stdlib.h&gt; #include &quot;point2d.h&quot; typedef struct private {   int x;   int y; } private;  static int getx(struct point2D*p) {    return ((struct private*)(p-&gt;prvtPoint2D))-&gt;x; } static void setx(struct point2D *p, int val) {     ((struct private*)(p-&gt;prvtPoint2D))-&gt;x = val; }  point2D* newPoint2D()  {   point2D* ptr;   ptr = (point2D*) malloc(sizeof(point2D));   ptr -&gt; prvtPoint2D = malloc(sizeof(private));   ptr -&gt; getX = &getx;   ptr -&gt; setX = &setx;   \/\/ ....   return ptr; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439, \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0442\u0442\u0435\u0440\u043e\u0432 \u0438 \u0433\u0435\u0442\u0442\u0435\u0440\u043e\u0432.  <\/p>\n<pre><code>\/\/ main.c #include &lt;stdio.h&gt; #include &quot;point2d.h&quot;  int main() {   point2D *point = newPoint2D();   int p = point-&gt;getX(point);   point-&gt;setX(point, 42);   p = point-&gt;getX(point);   printf(&quot;p = %d\\n&quot;, p);   deletePoint2D(point);   return 0; } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0432 \u00ab\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435\u00bb \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0438 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 private \u043f\u043e\u043b\u044f\u043c\u0438 \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u044d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u043e\u0442\u044f \u0431\u044b \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u0441\u0442\u0440\u0430\u0445\u043e\u0432\u0430\u043d \u043e\u0442 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 null-\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u0431\u043b\u0438\u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435. <\/p>\n<p>  <b>\u041d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435<\/b><br \/>  \u043a\u0430\u043a \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u044f\u0437\u044b\u043a\u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u0431\u0435\u0437 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c. \u0420\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0435\u0435 \u043f\u043e\u043b\u044f\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0432 C11 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0418\u0445 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u0430\u043a gcc, \u0442\u0430\u043a \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043e\u0442 microsoft. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0442\u0430\u043a.  <\/p>\n<pre><code>typedef struct point2D {   int x,y; } typedef struct point3D {     struct point2D;     int z; } point3D;  #include &lt;stdio.h&gt; #include &quot;point3d.h&quot;  int main() {   point3D *point = newPoint3D();   int p = point-&gt;x;   printf(&quot;p = %d\\n&quot;, p);   return 0; } <\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u043e \u0441 \u0444\u043b\u0430\u0433\u043e\u043c -fms-extensions. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u043e\u043b\u044f\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432 \u043e\u0431\u0445\u043e\u0434 \u0435\u0435 \u0438\u043c\u0435\u043d\u0438.<br \/>  \u041d\u043e \u043d\u0430\u0434\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u043d\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0442\u044c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <b>\u041f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c<\/b><br \/>  \u0412 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0438\u043f\u043e\u0432 \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c\u043e\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432. \u0418 \u0442\u0430\u043a\u0443\u044e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e _Generic, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u043e \u0432 \u042111. \u041d\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043d\u0435 \u0432\u0441\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 gcc \u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442. \u0412 _Generic \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u044b \u0442\u0438\u043f-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043e\u043d\u0438 \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043d\u0443\u0436\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0412 \u043e\u0431\u0449\u0435\u043c, \u043b\u0443\u0447\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0443\u0432\u0438\u0434\u0435\u0442\u044c.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u00ab\u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00bb, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0442\u0438\u043f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u043d\u0435\u0435, \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0435 \u0438\u043c\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438.  <\/p>\n<pre><code>\/\/points.h #define typename(x) _Generic((x), \\   point3D   : &quot;point3D&quot;, \\   point2D   : &quot;point2D&quot;, \\   point3D * : &quot;pointer to point3D&quot;, \\   point2D * : &quot;pointer to point2D&quot;  \\ )  \/\/main.c int main() {   point3D *point = newPoint3D();   puts(typename(point));   return 0; } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u0410 \u0440\u0430\u0437 _Generic \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u0435\u043c\u0443 \u043d\u0435 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u00ab\u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code>\/\/points.h double do2D(point2D *p); double do3D(point3D *p);    #define doSomething(X) _Generic((X), \\   point3D* : do3D, \\   point2D* : do2D \\ ) (X)  \/\/main.c int main() {   point3D *point = newPoint3D();   printf(&quot;d = %f\\n&quot;, doSomething(point));   return 0; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438.<\/p>\n<p>  <b>\u0421\u0442\u0430\u0442\u044c\u0438 \u043f\u043e \u0442\u0435\u043c\u0435:<\/b><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/205570\/\">habrahabr.ru\/post\/205570<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/154811\/\">habrahabr.ru\/post\/154811<\/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\/263547\/\"> http:\/\/habrahabr.ru\/post\/263547\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e20\/31a\/29a\/e2031a29a85745fd93008156a409d840.jpg\" height=\"42\" width=\"42\"\/><br \/>  \u042f\u0437\u044b\u043a \u0421\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c. \u0418 \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0435 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043d\u0438\u0436\u0435 \u044d\u0442\u043e \u043a\u043e\u0441\u0442\u044b\u043b\u0438 \u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b. <br \/>  \u041e\u041e\u041f \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f \u0442\u0440\u0438 \u0441\u0442\u043e\u043b\u043f\u0430: \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f, \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c. \u041d\u0438\u0436\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u044d\u0442\u0438\u0445 \u0432\u0435\u0449\u0435\u0439 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0432 \u0421.   <\/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-262284","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/262284","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=262284"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/262284\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=262284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=262284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=262284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}