Skip to content

Instantly share code, notes, and snippets.

@zhasm
Last active December 10, 2015 06:28
Show Gist options
  • Save zhasm/4394427 to your computer and use it in GitHub Desktop.
Save zhasm/4394427 to your computer and use it in GitHub Desktop.
像脚本语言一样运行 c 程序文件。放在 .bashrc / .bash_profile 环境中。
ccc ()
{
if [[ "$#" -lt 1 ]]; then
echo "Usage: $FUNCNAME <script.c> [optional_args]";
return;
else
file=$1;
shift;
args=$*;
out=`mktemp`;
gcc -O -Wall -W -pedantic -ansi -std=c99 -o $out $file;
if [ -x "$out" ]; then
$out $args;
else
echo "Compile error!";
fi;
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment