Last active
December 10, 2015 06:28
-
-
Save zhasm/4394427 to your computer and use it in GitHub Desktop.
像脚本语言一样运行 c 程序文件。放在 .bashrc / .bash_profile 环境中。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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