NO

Author Topic: C/C++ Interpreter  (Read 7135 times)

Offline akee

  • Member
  • *
  • Posts: 6
C/C++ Interpreter
« 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.

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: C/C++ Interpreter
« Reply #1 on: September 11, 2020, 01:32:59 PM »
You could try the  Tiny C Compiler or the older opiginal. 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.
« Last Edit: September 11, 2020, 01:34:54 PM by AlexN »
best regards
 Alex ;)

Offline akee

  • Member
  • *
  • Posts: 6
Re: C/C++ Interpreter
« Reply #2 on: September 11, 2020, 11:11:48 PM »
I believe TCC is no longer supported according to the creator.

Offline Robert

  • Member
  • *
  • Posts: 247
Re: C/C++ Interpreter
« Reply #3 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

Offline akee

  • Member
  • *
  • Posts: 6
Re: C/C++ Interpreter
« Reply #4 on: September 12, 2020, 12:05:32 PM »
tcc still generates .exe.

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: C/C++ Interpreter
« Reply #5 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.
« Last Edit: September 12, 2020, 11:10:45 PM by AlexN »
best regards
 Alex ;)

Offline akee

  • Member
  • *
  • Posts: 6
Re: C/C++ Interpreter
« Reply #6 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

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: C/C++ Interpreter
« Reply #7 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
/Pelle

Offline bitcoin

  • Member
  • *
  • Posts: 179
Re: C/C++ Interpreter
« Reply #8 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?

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: C/C++ Interpreter
« Reply #9 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...
/Pelle

Offline akee

  • Member
  • *
  • Posts: 6
Re: C/C++ Interpreter
« Reply #10 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.

Offline jack

  • Member
  • *
  • Posts: 66
Re: C/C++ Interpreter
« Reply #11 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

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: C/C++ Interpreter
« Reply #12 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.
/Pelle