These zsh scripts compiles and runs C/C++ programs in one line.
Currently, this package includes 2 scripts, c and ppc. Both of the syntaxes are the same, so only usage for C is shown here.
This program:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
}Can be run by using a single command:
# basic usage: compile a program and run it
c main.c
# or, for C++ programs
ppc main.cppResult:
Hello, World!
total 0.001
user 0.00s
sys 0.00s
mem 1 MB
# compile with parameters passed to gcc
c main.c -O2 main.cConsider this program:
#include <stdio.h>
int main(int argc, char **argv) {
printf("The first argument is %s\n", argv[1]);
printf("The second argument is %s\n", argv[2]);
}The parameters can be passed to it by using:
# arguments passed to the compiled program should be after the keyword `--params`
c main.c --params FIRST secondResult:
The first argument is FIRST
The second argument is second
total 0.001
user 0.00s
sys 0.00s
mem 1 MB
Arguments before --params will be passed to the compiler, so the command
c main.c -O2 -o test --params FIRST secondwill compile main.c with optimization O2, output to test, then run it with arguments FIRST and second.
./configure
make install