c 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
c 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
c 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT License
开发语言 C/C++
操作系统 跨平台
软件类型 开源软件
所属分类 开发工具编译器
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-11-08

软件简介

c

"There isn't much that's special about C. That's one of the reasons why it's fast."

I love C for its raw speed (although it does have its drawbacks). We should all write more C.

With this shell script, you can compile and execute C "scripts" in one go!

(Oh yeah, and it works for C++ too.)

GIF Demo

Here's a simple example:

#include <stdio.h>

int main(void) {
    printf("Hello World!\n");
    return 0;
}

Run it by typing:

$ c hello.c
Hello World!

Or, call it from the shebang!

#!/usr/bin/c
#include <stdio.h>

int main(void) {
    printf("Hello World!\n");
    return 0;
}
$ chmod +x hello.c
$ ./hello.c
Hello World!

Hooked? Here's how to install it:

Use a package manager? Check here.

For the entire system:

$ wget https://raw.githubusercontent.com/ryanmjacobs/c/master/c
$ sudo install -m 755 c /usr/bin/c

# Or... for systems that prefer /usr/local/bin (e.g. macOS)
$ sudo install -m 755 c /usr/local/bin/c

For your local user only:

$ wget https://raw.githubusercontent.com/ryanmjacobs/c/master/c
$ sudo install -Dm 755 c ~/.bin/c
$ echo 'PATH=$PATH:$HOME/.bin' >> ~/.bashrc

Note: if you install it somewhere other than /usr/bin/c, then your shebang will be different. For example it may be something more similar to #!/home/ryan/.bin/c.

Okay, how do I use it?

c will use whatever $CC is set to. You can change this with:

$ export CC=clang
$ export CC=tcc
$ # etc...

CLI

Multiple Files - CLI

Anything you want passed to the compiler, put in quotes as the first argument. Whether they're flags (-Wall, -O2, etc.) or file names (file.c, main.c, etc.).

$ c "main.c other.c" arg1 arg2
$ c "main.c other.c -O3 -Wall -lncurses" arg1 arg2

Single File - CLI

With only one file, omit the quotes:

$ c hello.c
$ c main.c arg1 arg2

Shebang!

After adding a shebang, just set the file to executable and it's ready to run.

$ chmod +x file.c
$ ./file.c

Single File - Shebang

Add this to the top of your C file:

#!/usr/bin/c

Multiple Files - Shebang

Just tack on any extra flags, options, or files you want passed to the compiler. Then be sure to add the terminating -- characters.

#!/usr/bin/c file1.c file2.c -lncurses -lm --

Caching

The default cache size is set to 5 MB. You can change this with:

$ export C_CACHE_SIZE=$((10*1024)) # 10 MB

The default cache path is set to $TMPDIR/c.cache. You can change this with:

$ export C_CACHE_PATH="/tmp/the_cache"

Contributing

Feel free to submit any ideas, questions, or problems by reporting an issue. Or, if you're feeling a bit brave, submit a pull request. 😬

Just hack away and make sure that all the tests pass.

$ cd tests
$ ./test.sh

Why?

First of all, I want to clarify why this is not the same as tcc -run. TCC is a compiler. We all know that. TCC will perform its own set of optimizations, just as GCC will perform its own and Clang will perform its own. The purpose of this script is to give a simple front-end to your favorite compiler.

Whether it's GCC, Clang, or something else entirely, you get to choose your compiler.

Second reason: it's simply satisfying to type c hello.c and see it run instantly.

Third reason: I'm a fan of speed, and C definitely offers it. Being able to write a small, fast, and portable C "script" is great. You can pass around a C "script" just like you would a BASH script.

zsh

If you're using zsh, then you can take advantage of zsh's suffix aliases:

$ alias -s c='c'
$ alias -s cc='c'
$ alias -s cpp='c'

Then you can run files with ./file.c without chmod +x.

Packages

Use a package manager? You've come to the right place.

AUR: https://aur.archlinux.org/packages/c/
bpkg: bpkg install ryanmjacobs/c
brew: brew install https://raw.githubusercontent.com/ryanmjacobs/c/master/c.rb (shebang will be #!/usr/local/bin/c)

Todo

Maybe later we can implement caching. Done!

License

MIT License.

Basically, you can do whatever you want provided that you include the LICENSE notice in any copy of the source. Also, I am not liable if the script breaks anything.

展开阅读全文

代码

评论 (0)

加载中
更多评论
暂无内容
发表于大前端专区
2020/04/29 09:17

c'c

1. 引入css 1. normalize.css 2. base.css,在里面引用normalize.css 3. 在app.vue引用base.css 2. 创建页面home,category,cart,profile 3. router配置 4. tabbaritem 难点在于判断item是否被点击 ```javascript isActive(){ return this.$route.path.indexOf('this.link')!=-1 } ``` ``` 点击后文字更改样式 activeStyle(){ return this.isActive?{'color':'#333'}:{} } ``` ## Request.js ``` import axios from 'axios' expo...

0
0
发表于大前端专区
2015/11/11 11:36

<c:if>没有<c:else>解决办法

最近在升级公司的一个老系统,05年的老系统。系统jsp页面没有使用Struts2的标签<s:if>,而是使用了<c:if>,问题来了,<c:if>是没有else语句的!! 下面的方法可以解决这个问题。 使用<c:if>的一般形式,即不需要else的时候: <%@ taglib uri="/WEB-INF/c.tld" prefix="c"%> <!--省略 -->    <c:if>    <!--如果 -->  </c:if> <c:if>没有<c:else>,当需要使用else的时候,我们可以用<c:choose>来取代结构: <%@ tag...

0
0
发表了博客
2019/04/10 10:10

dicom 影像通信(scu、scp)的c-echo、c-store、c-find、c-move

本文主要描述,dicom通信的scu,scp的c-echo、c-store、c-find、c-move的使用。 DicomService IDicomServiceProvider IDicomCStoreProvider IDicomCEchoProvider IDicomCFindProvider IDicomCMoveProvider IDicomTransformRule (1)c-echo 客户端代码: 1 DicomClient client = new DicomClient(); 2 client.AssociationAccepted += Client_AssociationAccepted; 3 client.Association...

0
0
发表了博客
2012/06/04 18:04

c

Compilers Borland Turbo C Clang GCC LCC Pelles C PCC TCC Visual C++ C++/CLI C++/CX Watcom C/C++ compiler Libraries C standard library glibc dietlibc uClibc Newlib EGLIBC Bionic musl Features String Syntax Preprocessor Variable types and declarations Functions...

0
0
发表了博客
2012/09/08 16:50

C

真的要学C 吗。。。。。还是

0
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
发表于开发技能专区
2021/11/12 11:51

knife4j一个Controller下的所有有Mapping都会被扫描?

一个Controller类下有很多请求,但是我只是想显示部分请求到文档中,有法配置嘛?

1
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部