Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opensourcedoc/ccrun
Run C or C++ Source Automatically
https://github.com/opensourcedoc/ccrun
c c-language c-plus-plus clang code-runner cpp freebsd gcc shell-script unix
Last synced: 6 days ago
JSON representation
Run C or C++ Source Automatically
- Host: GitHub
- URL: https://github.com/opensourcedoc/ccrun
- Owner: opensourcedoc
- License: mit
- Created: 2019-11-24T23:23:03.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T12:52:07.000Z (about 3 years ago)
- Last Synced: 2024-11-10T04:38:22.016Z (2 months ago)
- Topics: c, c-language, c-plus-plus, clang, code-runner, cpp, freebsd, gcc, shell-script, unix
- Language: Shell
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ccrun
`ccrun`, aka *C* or *C*++ *Run*ner, compiles and executes C or C++ code base automatically.
## Warning
`ccrun` will compile and execute target source. Hence, DON'T USE `ccrun` to run UNTRUSTED source.
## Why `ccrun`?
C or C++ are compiled languages. We have to compile its source before executing it. Nevertheless, it is tedious to compile C or C++ source manually. For small code base, it is overkill to write Makefile or other project configuration file as well.
To address the issue, `ccrun` can automatically compile and execute C or C++ source without any project configuration file, handy for small code base.
## System Requirements
`ccrun` itself is written in POSIX shell. Besides, you need a C or C++ compiler to compile target source.
By default, `ccrun` will invoke `gcc` or `g++` for compilation tasks. You may change to another C or C++ compiler by setting related environment variables.
We tested `ccrun` against several Unix or Unix-like systems:
* Ubuntu 20.04 LTS
* Rocky Linux 8.5
* openSUSE Leap 15.3
* FreeBSD 13.0It should work on other Unix or Unix-like systems as well.
## Supported File Formats
`ccrun` supports the following file formats:
* *.c* for C source
* *.cpp*, *.cxx* or *.cc* for C++ source`ccrun` can handle projects that mix C and C++ together.
## Usage
Add exec mode for `ccrun` before using it:
```
$ chmod +x path/to/ccrun
```It is recommended to copy `ccrun` to a valid **$PATH** like *$HOME/bin* or */usr/local/bin*.
Run single source:
```
$ ccrun path/to/file.c
```Run multiple sources in a project:
```
$ ccrun path/to/*.c
```Run multiple C and C++ mixed sources in a project:
```
$ ccrun path/to/*.c path/to/*.cpp
```Run target sources with arguments:
```
$ ccrun path/to/*.c -- --opt param_a param_b param_c
```## Environment Variables
You can adjust the behavior of `ccwarn` with the following environment variables:
* **CC** to set GCC compiler
* **CXX** to set G++ compiler
* **OUT_FILE** to set the name of a temporary output file
* **CFLAGS** to set custom include paths and compiler flags for C
* **CXXFLAGS** to set custom include paths and compiler flags for C++
* **LDFLAGS** to set custom lib paths
* **LIBS** to set custom library linkages
* **LD_LIBRARY_PATH** to set custom binary file pathsAll environment variables are optional, set with sensible default values.
## Note
If you want to check code quality and conform some language standard for your C or C++ source, see [ccwarn](https://github.com/cwchentw/ccwarn).
## Copyright
Copyright (c) 2019 Michelle Chen. Licensed under [MIT](https://opensource.org/licenses/MIT).