LoginSignup
11
11

More than 5 years have passed since last update.

コンパイルしないC言語

Last updated at Posted at 2015-07-08

オリジナルはkazuho/Cです。

makeを再開発する記事を見たときに、2003年ころC言語をオンザフライでコンパイルしてワンライナーが書けるようなものがあったのを思い出してぐぐってみたけど見つからなかったので、代替するものを探してみんとす。

ちなみに似たものを再現してみた。このようにフィルタコマンドとして使えなくもないが、シェル芸向きではないと強く思う。

~/s/c ❯❯❯ echo "Hello world" | ./c 'char x[256];fgets(x,sizeof(x),stdin);puts(x)'
Hello world
#!/usr/bin/env bash

temp=$(mktemp /tmp/cXXXXXX)

{
  echo '#include <stdio.h>'
  echo 'int main(int argc, char *argv[]){'
  echo $@
  echo ';}'
} >> $temp.c

#cat $temp.c

{
  cc -o $temp.o $temp.c
  $temp.o < /dev/stdin
}

同様に、明示的にコンパイルしないプロダクトも幾つかあるようだ。

ryanmjacobs/c
https://github.com/ryanmjacobs/c

.cをccして.oを実行するだけのやつ。C言語をシーバンで実行できる。ググラビリティ…。

picoc
https://github.com/zsaleeba/picoc

インタプリタ。

CINT
https://root.cern.ch/drupal/content/cint

C,C++インタプリタ。

Cling
https://root.cern.ch/drupal/content/cling

C++インタプリタ。LLVMベース。

StudyC
http://www.orchid.co.jp/soft/studyc.html

Windows用。

まあウェブベースで実行できるideoneとか使ったほうが楽な気はする。

11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11