{"id":1030,"date":"2010-11-02T19:15:13","date_gmt":"2010-11-02T11:15:13","guid":{"rendered":"http:\/\/blog.pighead.cc\/whsyu\/?p=1030"},"modified":"2010-11-02T19:15:13","modified_gmt":"2010-11-02T11:15:13","slug":"messages-of-clang-and-gcc","status":"publish","type":"post","link":"https:\/\/blog.pighead.cc\/whsyu\/2010\/11\/02\/messages-of-clang-and-gcc\/","title":{"rendered":"clang \u53ca gcc \u7684\u7de8\u8b6f\u8a0a\u606f"},"content":{"rendered":"<p class=\"bb-post-separator\"><strong>[\u83ef\u8a9e, cmn-Hant-TW]  <\/strong><\/p><p>\u56e0\u70ba GPLv3 \u7684\u554f\u984c\uff0cFreeBSD \u5c07\u4f86\u7684\u9810\u8a2d\u7de8\u8b6f\u5668\u6703\u5f9e gcc \u5f80 clang \u79fb\u52d5\u3002<a href=\"http:\/\/clang.llvm.org\/\">clang<\/a> \u7684\u8ce3\u9ede\u4e4b\u4e00\u5c31\u662f\u7de8\u8b6f\u7684\u8a0a\u606f\u8f03\u6613\u61c2\uff0c\u4e00\u500b\u7c21\u55ae\u7684\u4f8b\u5b50<\/p>\n<pre lang=\"c\" line=\"1\">\r\n#include &lt;stdio.h&gt;\r\n\r\nmain () {\r\n  int a\r\n  int b;\r\n}<\/pre>\n<h5>gcc version 4.2.1 20070719  [FreeBSD] <\/h5>\n<pre lang=\"none\">\r\nft.c:3: warning: return type defaults to 'int'\r\nft.c: In function 'main':\r\nft.c:5: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'\r\nft.c:5: warning: unused variable 'b'\r\nft.c:6: warning: control reaches end of non-void function\r\n<\/pre>\n<h5>clang version 2.8 (trunk)<\/h5>\n<pre lang=\"none\">\r\nft.c:3:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]\r\nmain () {\r\n^\r\nft.c:4:8: error: expected ';' at end of declaration\r\n  int a\r\n       ^\r\n       ;\r\n1 warning and 1 error generated.\r\n<\/pre>\n<p>gcc \u6709\u52a0 -Wall \u53c3\u6578\u628a warning \u5370\u51fa\u4f86\uff0c\u9810\u8a2d\u662f\u53ea\u6703\u5370\u51fa\u7b2c 5 \u884c\u6709 error \u7684\u8a0a\u606f\u3002\u5f88\u660e\u986f clang \u7684\u8f38\u51fa\u8f03\u5177\u6709\u53ef\u8b80\u6027\uff0c\u4ed6\u660e\u78ba\u6307\u51fa\u7b2c 4 \u884c\u5fd8\u4e86\u52a0\u5206\u865f (;) \u800c\u4e0d\u662f\u8aaa\u7b2c 5 \u884c\u524d\u9762\u6f0f\u4e86\u4ec0\u9ebc\u6771\u897f\uff0c\u53e6\u5916\u82e5 Terminal \u6709\u652f\u63f4\u7684\u8a71\uff0c\u4ed6\u7684\u4e00\u4e9b\u95dc\u9375\u5b57\u53ca\u6a19\u793a\u4f4d\u7f6e\u7684\u7b26\u865f(^)\u9084\u6703\u7528\u4e0d\u540c\u7684\u984f\u8272\u8868\u793a\uff0c\u53ef\u4ee5\u5f88\u6e05\u695a\u7684\u770b\u51fa\u554f\u984c\u51fa\u5728\u54ea\u88e1\u3002<\/p>\n<p>\u5e0c\u671b clang \u80fd\u6108\u4f86\u6108\u666e\u53ca\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[\u83ef\u8a9e, cmn-Hant-TW] \u56e0\u70ba GPLv3 \u7684\u554f\u984c\uff0cFreeBSD \u5c07\u4f86\u7684\u9810\u8a2d\u7de8\u8b6f\u5668\u6703\u5f9e gcc \u5f80 clang \u79fb\u52d5\u3002clang \u7684\u8ce3\u9ede\u4e4b\u4e00\u5c31\u662f\u7de8\u8b6f\u7684\u8a0a\u606f\u8f03\u6613\u61c2\uff0c\u4e00\u500b\u7c21\u55ae\u7684\u4f8b\u5b50 #include &lt;stdio.h&gt; main () { int a int b; } gcc version 4.2.1 20070719 [FreeBSD] ft.c:3: warning: return type defaults to &#8216;int&#8217; ft.c: In function &#8216;main&#8217;: ft.c:5: error: expected&hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[200],"tags":[4263,4264],"class_list":["post-1030","post","type-post","status-publish","format-standard","hentry","category-development","tag-clang","tag-gcc"],"_links":{"self":[{"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/posts\/1030","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/comments?post=1030"}],"version-history":[{"count":36,"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/posts\/1030\/revisions"}],"predecessor-version":[{"id":1067,"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/posts\/1030\/revisions\/1067"}],"wp:attachment":[{"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/media?parent=1030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/categories?post=1030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pighead.cc\/whsyu\/wp-json\/wp\/v2\/tags?post=1030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}