C有翻译吗?

时间:2021-05-08 20:44:15

I was wondering if there is something like an interpreter for C. That is, in a Linux terminal I can type in "python" and then code in that interpreter. (I'm not sure interpreter the right word). This is really helpful for testing different things out and I'm curious if something similar exists for C. Though I doubt it. The only thing I can think of that would do it would be the C shell...

我想知道是否有类似于c语言的解释器,也就是说,在Linux终端中,我可以输入“python”,然后在那个解释器中编写代码。(我不确定翻译是否正确)。这对于测试不同的东西很有帮助,我很好奇c是否存在类似的东西,尽管我对此表示怀疑。我唯一能想到的就是C层。

13 个解决方案

#1


72  

There are many - if you narrow down the scope of your question we might be able to suggest some specific to your needs.

有很多-如果你缩小你的问题的范围,我们可能可以提出一些具体的需求。

A notable interpreter is "Ch: A C/C++ Interpreter for Script Computing" detailed in Dr. Dobbs:

一个值得注意的解释器是“Ch: C/ c++脚本计算解释器”,详见Dobbs博士:

Ch is a complete C interpreter that supports all language features and standard libraries of the ISO C90 Standard, but extends C with many high-level features such as string type and computational arrays as first-class objects.

Ch是一个完整的C解释器,它支持ISO C90标准的所有语言特性和标准库,但扩展了C的许多高级特性,如字符串类型和计算数组作为一级对象。

Ch standard is freeware but not open source. Only Ch professional has the plotting capabilities and other features one might want.

Ch标准是免费的,但不是开源的。只有Ch professional具有绘图能力和其他特性。

I've never looked at this before, but having a c interpreter on hand sounds very useful, and something I will likely add to my toolset. Thanks for the question!

我以前从未研究过这个问题,但是手头有一个c解释器听起来很有用,我可能会在工具集中添加一些东西。谢谢你的问题!


Edit:

编辑:

Just found out that one of my favorite compilers, TCC, will execute C scripts:

刚刚发现我最喜欢的编译器之一TCC将执行C脚本:

It also handles C script files (just add the shebang line "#!/usr/local/bin/tcc -run" to the first line of your C source code file on Linux to have it executed directly.

它还可以处理C脚本文件(只需添加shebang行“#!”/usr/local/bin/tcc -run到Linux上C源代码文件的第一行,直接执行。

TCC can read C source code from standard input when '-' is used in place of 'infile'. Example:

当使用'-'代替'infile'时,TCC可以从标准输入中读取C源代码。例子:

echo 'main(){puts("hello");}' | tcc -run -

#2


18  

picoc - A very small C interpreter

picoc -一个非常小的C解释器

PicoC is a very small C interpreter for scripting. It was originally written as the script language for a UAV's on-board flight system. It's also very suitable for other robotic, embedded and non-embedded applications.

PicoC是编写脚本的一个非常小的C解释器。它最初是作为无人机机载飞行系统的脚本语言编写的。它也非常适合其他机器人,嵌入式和非嵌入式应用。

#3


9  

the ROOT project provides a very functional C and C++ interpreter called Cint. I'm quite fond of it. It takes a little getting used to interpretively, though.

根项目提供了一个非常有用的C和c++解释器Cint。我很喜欢它。不过,需要一点时间来适应这种解释。

TCC is a very good choice as well, but i'm not able to vouch for its REPL

TCC也是一个很好的选择,但是我不能担保它的REPL

#4


8  

Probably. There are several for c++. See Have you used any of the C++ interpreters (not compilers)? for examples. Certainly cint will eat nearly any c code with good results, and tcc is so fast that you can use it like a interpreter.

可能。c++有几种。您是否使用过c++解释器(不是编译器)?为例子。当然cint将会吃几乎任何有好的结果的c代码,并且tcc是如此的快以至于你可以像一个解释器一样使用它。

#5


7  

Give a look to the Ch Interpreter.

看一下Ch口译员。

Ch is an embeddable C/C++ interpreter for cross-platform scripting, shell programming, 2D/3D plotting, numerical computing, and embedded scripting.

Ch是一个可嵌入的C/ c++解释器,用于跨平台脚本编写、shell编程、2D/3D绘图、数值计算和嵌入式脚本。

#6


6  

I know we use CINT in class. It seemed pretty good you might want to give it a try!

我知道我们在课堂上使用CINT。看起来不错,你可能想试试!

#7


5  

Check Out iGCC

看看iGCC

#8


4  

cinterp is one for a start.

cinterp就是一个起点。

#9


3  

ccons appears to satisfy your constraints:

ccons似乎满足您的限制:

The goal of the ccons project is to create an interactive console for the C programming language, similar to "python" and "irb" for Python and Ruby respectively. The project builds on top of clang and llvm.

ccons项目的目标是为C语言创建一个交互控制台,类似于python和Ruby的“python”和“irb”。该项目构建在clang和llvm之上。

#10


2  

More recently there is Cling (based on LLVM/Clang)

最近出现了依赖(基于LLVM/Clang)

http://root.cern.ch/drupal/content/cling

http://root.cern.ch/drupal/content/cling

#11


2  

You can use CompCert. Here are some examples: http://compcert.inria.fr/man/manual004.html

您可以使用CompCert。这里有一些例子:http://compcert.inria.fr/man/manual004.html

#12


1  

It has been done, even though the vast majority of C work is compiled. One example is CH

尽管C的绝大部分工作都是编译的,但是它已经完成了。一个例子是CH

#13


0  

CERN has a toolkit called ROOT, which is meant mainly for scientific or data analysis etc.. purposes but it has a Clang - based C/C++ Interpreter called Cling.

CERN有一个名为ROOT的工具包,主要用于科学或数据分析等。但是它有一个基于Clang的C/ c++解释器,叫做stick。

They were using a C interpreter called CINT before they adapted Cling. CINT is lightweight & still seems to be available for download.

在他们适应依附之前,他们使用了一个叫做CINT的C翻译。CINT是轻量级的&似乎仍然可以下载。

I think you may get some other by carefully searching through Wikipedia list articles.

我认为你可以通过仔细搜索*上的文章找到其他的。

#1


72  

There are many - if you narrow down the scope of your question we might be able to suggest some specific to your needs.

有很多-如果你缩小你的问题的范围,我们可能可以提出一些具体的需求。

A notable interpreter is "Ch: A C/C++ Interpreter for Script Computing" detailed in Dr. Dobbs:

一个值得注意的解释器是“Ch: C/ c++脚本计算解释器”,详见Dobbs博士:

Ch is a complete C interpreter that supports all language features and standard libraries of the ISO C90 Standard, but extends C with many high-level features such as string type and computational arrays as first-class objects.

Ch是一个完整的C解释器,它支持ISO C90标准的所有语言特性和标准库,但扩展了C的许多高级特性,如字符串类型和计算数组作为一级对象。

Ch standard is freeware but not open source. Only Ch professional has the plotting capabilities and other features one might want.

Ch标准是免费的,但不是开源的。只有Ch professional具有绘图能力和其他特性。

I've never looked at this before, but having a c interpreter on hand sounds very useful, and something I will likely add to my toolset. Thanks for the question!

我以前从未研究过这个问题,但是手头有一个c解释器听起来很有用,我可能会在工具集中添加一些东西。谢谢你的问题!


Edit:

编辑:

Just found out that one of my favorite compilers, TCC, will execute C scripts:

刚刚发现我最喜欢的编译器之一TCC将执行C脚本:

It also handles C script files (just add the shebang line "#!/usr/local/bin/tcc -run" to the first line of your C source code file on Linux to have it executed directly.

它还可以处理C脚本文件(只需添加shebang行“#!”/usr/local/bin/tcc -run到Linux上C源代码文件的第一行,直接执行。

TCC can read C source code from standard input when '-' is used in place of 'infile'. Example:

当使用'-'代替'infile'时,TCC可以从标准输入中读取C源代码。例子:

echo 'main(){puts("hello");}' | tcc -run -

#2


18  

picoc - A very small C interpreter

picoc -一个非常小的C解释器

PicoC is a very small C interpreter for scripting. It was originally written as the script language for a UAV's on-board flight system. It's also very suitable for other robotic, embedded and non-embedded applications.

PicoC是编写脚本的一个非常小的C解释器。它最初是作为无人机机载飞行系统的脚本语言编写的。它也非常适合其他机器人,嵌入式和非嵌入式应用。

#3


9  

the ROOT project provides a very functional C and C++ interpreter called Cint. I'm quite fond of it. It takes a little getting used to interpretively, though.

根项目提供了一个非常有用的C和c++解释器Cint。我很喜欢它。不过,需要一点时间来适应这种解释。

TCC is a very good choice as well, but i'm not able to vouch for its REPL

TCC也是一个很好的选择,但是我不能担保它的REPL

#4


8  

Probably. There are several for c++. See Have you used any of the C++ interpreters (not compilers)? for examples. Certainly cint will eat nearly any c code with good results, and tcc is so fast that you can use it like a interpreter.

可能。c++有几种。您是否使用过c++解释器(不是编译器)?为例子。当然cint将会吃几乎任何有好的结果的c代码,并且tcc是如此的快以至于你可以像一个解释器一样使用它。

#5


7  

Give a look to the Ch Interpreter.

看一下Ch口译员。

Ch is an embeddable C/C++ interpreter for cross-platform scripting, shell programming, 2D/3D plotting, numerical computing, and embedded scripting.

Ch是一个可嵌入的C/ c++解释器,用于跨平台脚本编写、shell编程、2D/3D绘图、数值计算和嵌入式脚本。

#6


6  

I know we use CINT in class. It seemed pretty good you might want to give it a try!

我知道我们在课堂上使用CINT。看起来不错,你可能想试试!

#7


5  

Check Out iGCC

看看iGCC

#8


4  

cinterp is one for a start.

cinterp就是一个起点。

#9


3  

ccons appears to satisfy your constraints:

ccons似乎满足您的限制:

The goal of the ccons project is to create an interactive console for the C programming language, similar to "python" and "irb" for Python and Ruby respectively. The project builds on top of clang and llvm.

ccons项目的目标是为C语言创建一个交互控制台,类似于python和Ruby的“python”和“irb”。该项目构建在clang和llvm之上。

#10


2  

More recently there is Cling (based on LLVM/Clang)

最近出现了依赖(基于LLVM/Clang)

http://root.cern.ch/drupal/content/cling

http://root.cern.ch/drupal/content/cling

#11


2  

You can use CompCert. Here are some examples: http://compcert.inria.fr/man/manual004.html

您可以使用CompCert。这里有一些例子:http://compcert.inria.fr/man/manual004.html

#12


1  

It has been done, even though the vast majority of C work is compiled. One example is CH

尽管C的绝大部分工作都是编译的,但是它已经完成了。一个例子是CH

#13


0  

CERN has a toolkit called ROOT, which is meant mainly for scientific or data analysis etc.. purposes but it has a Clang - based C/C++ Interpreter called Cling.

CERN有一个名为ROOT的工具包,主要用于科学或数据分析等。但是它有一个基于Clang的C/ c++解释器,叫做stick。

They were using a C interpreter called CINT before they adapted Cling. CINT is lightweight & still seems to be available for download.

在他们适应依附之前,他们使用了一个叫做CINT的C翻译。CINT是轻量级的&似乎仍然可以下载。

I think you may get some other by carefully searching through Wikipedia list articles.

我认为你可以通过仔细搜索*上的文章找到其他的。