将C或C ++文件作为脚本运行 [英] Run C or C++ file as a script

查看:70
本文介绍了将C或C ++文件作为脚本运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这可能是一个远景,但是有什么方法可以将C或C ++文件作为脚本运行吗?我试过了:

So this is probably a long shot, but is there any way to run a C or C++ file as a script? I tried:

#!/usr/bin/gcc main.c -o main; ./main

int main(){ return 0; }

但它说:

./main.c:1:2: error: invalid preprocessing directive #!


推荐答案

对于C,您可以看看 tcc 。将C代码作为脚本运行是其可能的用途之一。

For C, you may have a look at tcc, the Tiny C Compiler. Running C code as a script is one of its possible uses.

这篇关于将C或C ++文件作为脚本运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆