{"id":28167,"date":"2015-03-06T00:59:28","date_gmt":"2015-03-05T15:59:28","guid":{"rendered":"http:\/\/www.softantenna.com\/wp\/?p=28167"},"modified":"2015-03-06T00:59:28","modified_gmt":"2015-03-05T15:59:28","slug":"c-script","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/c-script\/","title":{"rendered":"C - C\u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u7684\u306b\u5b9f\u884c\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2015\/03\/I-2015-03-06-0.36.30.png\" alt=\"2015 03 06 0 36 30\" title=\" 2015-03-06 0.36.30.png\" border=\"0\" width=\"546\" height=\"264\" \/><\/p>\n<p>C\u8a00\u8a9e\u306f\u30b3\u30f3\u30d1\u30a4\u30e9\u3092\u4f7f\u3063\u3066\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u5b9f\u884c\u3059\u308b\u300c\u30b3\u30f3\u30d1\u30a4\u30e9\u578b\u8a00\u8a9e\u300d\u306e\u4ee3\u8868\u3068\u898b\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306eC\u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u3042\u305f\u304b\u3082\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3042\u308b\u304b\u306e\u3088\u3046\u306b\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u300c<a href=\"https:\/\/github.com\/ryanmjacobs\/c\">C<\/a>\u300d\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059(<a href=\"https:\/\/news.ycombinator.com\/item?id=9144467\">Hacker News<\/a>)\u3002<\/p>\n<p>C\u3092\u4f7f\u3048\u3070\u3001\u300cc hello.c\u300d\u3068\u304b\u3001shebang\u3092\u4f7f\u3063\u3066\u300c.\/hello.c\u300d\u306e\u3088\u3046\u306b\u3001C\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u901a\u5e38\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u306e\u3088\u3046\u306b\u5b9f\u884c\u3067\u304d\u308b\u306e\u3067\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/h2>\n<p>git clone\u3057\u3066c\u3092\u30d1\u30b9\u306b\u30b3\u30d4\u30fc\u3059\u308b\u306e\u304c\u7c21\u5358\u3067\u3059\u3002<\/p>\n<pre>\n$ git clone https:\/\/github.com\/ryanmjacobs\/c\n$ sudo cp .\/c\/c \/usr\/bin\/c\n<\/pre>\n<p>\/usr\/bin\u306f\u3061\u3087\u3063\u3068\u2026\u3068\u3044\u3046\u5834\u5408\u306f\u3001\/usr\/local\/bin\u3084\u3001~\/bin\u306a\u3069\u304a\u597d\u307f\u306e\u5834\u6240\u306b\u30b3\u30d4\u30fc\u3057\u3066\u30d1\u30b9\u3092\u901a\u3057\u3066\u304a\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u5b9f\u884c\u65b9\u6cd5<\/h2>\n<p>examples\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u3067\u305d\u308c\u3092\u52d5\u304b\u3059\u306e\u304c\u624b\u3063\u53d6\u308a\u65e9\u3044\u3067\u3059\u3002<\/p>\n<pre>\n$ cd examples\n$ more hello.c\n#!\/usr\/bin\/c\n#include <stdio.h>\n\nint main(void) {\n    puts(\"Hello World!\");\n    return 0;\n}\n$ c hello.c\nHello World!\n<\/pre>\n<p>\u5c11\u3057\u6c17\u6301\u3061\u60aa\u3044\u6c17\u3082\u3057\u307e\u3059\u304c\u3001\u3061\u3083\u3093\u3068\u300cHello World!\u300d\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u52d5\u304d\u307e\u3057\u305f\u3002\u5358\u7d14\u306a1\u30d5\u30a1\u30a4\u30eb\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3060\u3051\u3067\u306a\u304f\u3001\u8907\u6570\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u305f\u308a\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u6307\u5b9a\u3057\u305f\u308a\u3068\u3044\u3063\u305f\u3053\u3068\u3082\u30aa\u30d7\u30b7\u30e7\u30f3\u6307\u5b9a\u306b\u3088\u3063\u3066\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h2>\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u306e\uff1f<\/h2>\n<p>c\u30b3\u30de\u30f3\u30c9\u306f\u5b9f\u969b\u306fbash\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u51e6\u7406\u306e\u30ad\u30e2\u306e\u90e8\u5206\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre><code class=\"sh\"># compile and run\nif \"$CC\" -I\"$(pwd)\" -O2 -o \"$binname\" ${comp[@]}; then\n    shift\n    (exec -a \"$fname\" \"$binname\" \"$@\")\n    ret=$?\nelse\n    ret=1\nfi\n<\/code><\/pre>\n<p>\u8981\u306f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u3001C\u30b3\u30f3\u30d1\u30a4\u30e9\u3067\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u5b9f\u884c\u3057\u3066\u3044\u308b\u3060\u3051\u2026\u3068\u3044\u3046\u8003\u3048\u3066\u307f\u308c\u3070\u5f53\u305f\u308a\u524d\u306a\u4f5c\u308a\u3068\u306a\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u8a66\u3057\u306b\u30a8\u30e9\u30fc\u306b\u306a\u308b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u5b9f\u884c\u3055\u305b\u3066\u307f\u308b\u3068\u3001\u51e6\u7406\u304c\u3088\u308a\u660e\u78ba\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>\n$ c hello_error.c\n\/var\/folders\/pf\/gvc5xz_j52b92qwl9y0vwdm40000gq\/T\/c.XXX.9CXS0xvo\/hello_error.c:4:1: error:\n      unknown type name 'nt'\nnt main(void) {\n^\n1 error generated.\n<\/pre>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>C\u8a00\u8a9e\u306e\u30b3\u30f3\u30d1\u30a4\u30eb=\u91cd\u3044\u51e6\u7406\u3001\u3068\u601d\u3044\u304c\u3061\u3067\u3059\u304c\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u77ed\u3044\u305b\u3044\u304b\u3001\u30de\u30b7\u30f3\u30d1\u30ef\u30fc\u306e\u305b\u3044\u304b\u3001SSD\u306e\u305b\u3044\u304b\u3001\u601d\u3044\u306e\u307b\u304b\u30b5\u30af\u30b5\u30af\u52d5\u3044\u3066\u610f\u5916\u306a\u6c17\u304c\u3057\u307e\u3057\u305f\u3002\u7c21\u5358\u306aC\u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u3061\u3087\u3063\u3068\u52d5\u304b\u3057\u3066\u307f\u305f\u3044\u3001\u3068\u3044\u3063\u305f\u7528\u9014\u3060\u3068\u5b9f\u7528\u7684\u306b\u4f7f\u3048\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C\u8a00\u8a9e\u306f\u30b3\u30f3\u30d1\u30a4\u30e9\u3092\u4f7f\u3063\u3066\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u5b9f\u884c\u3059\u308b\u300c\u30b3\u30f3\u30d1\u30a4\u30e9\u578b\u8a00\u8a9e\u300d\u306e\u4ee3\u8868\u3068\u898b\u3089\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306eC\u8a00\u8a9e\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u3042\u305f\u304b\u3082\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3042\u308b\u304b\u306e\u3088\u3046\u306b\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u300cC\u300d\u304c\u516c\u958b\u3055\u308c\u3066\u3044\u307e\u3059( [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":28166,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[75],"tags":[534,2920],"class_list":["post-28167","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-c","tag-script"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/28167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=28167"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/28167\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/28166"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=28167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=28167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=28167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}