Pelles C forum

Pelles C => Feature requests => Topic started by: akee on September 11, 2020, 08:38:38 AM

Title: C/C++ Interpreter
Post by: akee on September 11, 2020, 08:38:38 AM
Could we have a C/C++ Interpreter to go along with the setup that you can install separately?
Then all we need is to keep our source code for doing common administrative tasks rather than having many .exe.

Thanks for contributing to the community.
Title: Re: C/C++ Interpreter
Post by: AlexN on September 11, 2020, 01:32:59 PM
You could try the  Tiny C Compiler (http://download.savannah.nongnu.org/releases/tinycc/) or  the older opiginal (https://bellard.org/tcc/). It is a compiler not an interpreter, but it has the option -run. With this option it compiles (very fast) to the RAM and executes immediate.
Perhaps this is something you are looking for.

And when all works, you still can decide to build an EXE.
Title: Re: C/C++ Interpreter
Post by: akee on September 11, 2020, 11:11:48 PM
I believe TCC is no longer supported according to the creator.
Title: Re: C/C++ Interpreter
Post by: Robert on September 12, 2020, 01:19:42 AM
I believe TCC is no longer supported according to the creator.

tinycc git repository Last change   Fri, 11 Sep 2020 08:15:39 -0700 (11 23:15 +0800)

Website and Git Downloads at

https://repo.or.cz/w/tinycc.git (https://repo.or.cz/w/tinycc.git)
Title: Re: C/C++ Interpreter
Post by: akee on September 12, 2020, 12:05:32 PM
tcc still generates .exe.
Title: Re: C/C++ Interpreter
Post by: AlexN on September 12, 2020, 11:09:01 PM
tcc still generates .exe.
Yes, but when you use the parameter -run the program is only compiled and linked to the RAM and is executet directly after compilation and no EXE is generated.

For your problem the magic parameter is -run.
Title: Re: C/C++ Interpreter
Post by: akee on September 13, 2020, 03:11:05 PM
got this error...

Code: [Select]
tcc: error: -run is not available in a cross compiler
I think I will stick to VBScript. Thanks for the help. ;D
Title: Re: C/C++ Interpreter
Post by: Pelle on September 13, 2020, 05:04:26 PM
I havn't tried it myself, but if it was good enough for "Large Hadron Collider experiements at CERN" it can't be all bad (one would hope):
http://www.hanno.jp/gotom/Cint.html (http://www.hanno.jp/gotom/Cint.html)
Title: Re: C/C++ Interpreter
Post by: bitcoin on September 13, 2020, 06:43:29 PM
Pelle, sorry for the offtopic, but is it difficult to write your own compiler? What do you need to know for this?
Title: Re: C/C++ Interpreter
Post by: Pelle on September 13, 2020, 09:14:18 PM
Pelle, sorry for the offtopic, but is it difficult to write your own compiler? What do you need to know for this?

Like any "large" program there are lots details, but each detail isn't necessarily that difficult.

One way to start is by looking at an already written compiler, for a programming language you understand. The more comments, the better...

Maybe search GitHub, or try a web search for "tiny" + "compiler" + ... for something to start with. Once you understand things better, you can do at new search with different terms/keywords. Most of what I have learned about compilers in recent years comes from web searches...
Title: Re: C/C++ Interpreter
Post by: akee on September 14, 2020, 06:55:57 AM
Firstly, thank you Pelle for your contribution to the C community.

I think CInt has been superseded by Cling (also by CERN) but I could only find Linux zips.
Title: Re: C/C++ Interpreter
Post by: jack on September 14, 2020, 02:19:07 PM
ROOT https://root.cern/ uses Cling and you can get a Windows preview of ROOT at https://root.cern/releases/release-62202/
I looked at the archive and there's no Cling exe but there's a dll, so I am guessing it should be possible to embed Cling in your application using the dll
Title: Re: C/C++ Interpreter
Post by: Pelle on September 14, 2020, 08:02:11 PM
AFAIK, Cling is based on LLVM - which seems to be in a constant "almost there" mode (at least in my experience).
My hope was that CInt would be more stable and mature. YMMV.