Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yugr/gcc-interp

Run C files as standalone scripts
https://github.com/yugr/gcc-interp

c cplusplus interpreter proof-of-concept script

Last synced: about 1 month ago
JSON representation

Run C files as standalone scripts

Awesome Lists containing this project

README

        

`gcci` allows to run C files as scripts, omitting the compilation step
(actually hiding it). Most importantly, modified file still remains
a valid C code and can be compiled by normal means.

Self-executable C code is particularly useful when you make
a library of small examples/snippets.

Example usage:
```
$ cat hello.c
#include
int main() {
printf("Hello world!\n");
return 0;
}

# Insert "shebang"
$ gcci -i hello.c

# Run!
$ ./hello.c
Hello world!
```

You can also execute without instrumentation:
```
$ gcci hello.c
Hello world!
```

If you get `gcci: command not found` error in last line, you need to add `gcci` to `PATH`
or use absolute path instead:
```
$ gcci -i -a ...
```

To override default compilation flags (`-Wall -DNDEBUG -O2`) use `--compiler-flags` option
during instrumentation stage:
```
$ gcci -i --compiler-flags='-O0 -w' ...
```

`gcci` is based on a hack from [What's the appropriate Go shebang line?](https://stackoverflow.com/questions/7707178/whats-the-appropriate-go-shebang-line)

TODO:
* add compilation cache (in `$HOME/.gcci`)