Does "root" do what you want?
https://root.cern/
https://root.cern/primer/#learn-c-at-the-root-prompt
Includes a c++ interpreter (which includes all of C) that interprets C as
you go, then at your option, compile a just-interpreted function,
dynamically link it, and use the compiled version of that function in
further interpreted commands.

I think this (root) is under-appreciated or unknown by C community.


On Sat, Dec 28, 2024 at 3:49 AM Basile Starynkevitch <
bas...@starynkevitch.net> wrote:

> Hello all,
>
> Paul Markfort suggested
> >
> > This is just a suggestion to make it easier for Linux/Unix users to
> > use the Gnu compilers instead of having to use a scripting language
> > for short little utilities.
> >
> > I know someone has created and released a binary C interpreter for
> > this purpose.
> > But why would you want to install another program, if you could
> > essentially use the tools you already have.
> >
> > I think gcc (and all the compilers) should support the "#!" in source
> > files to make something similar easily possible.
>
>
> I agree with that suggestion.
>
> On Linux, there are limitations given by execve(2) system call.
> I observe that Clang/LLVM people might disagree with it.
>
> One of the issues is that we could want several C files compiled into
> one shared library.
>
> Another of the issues is that we could want to specify different code
> generation or optimizations. Perhaps the second non comment line could
> be some #pragma.
>
> GCC allows the standard input to be used.
>
> Maybe a possibility might be to have a /usr/bin/gcc-stdin executable?
>
> Observe that tinycc (a quick non-optimizing open source C compiler)
> already has the wanted feature
> https://en.wikipedia.org/wiki/Tiny_C_Compiler
>
> > TCC-DOC(1)                                        Tiny C Compiler
> > TCC-DOC(1)
> >
> > NAME
> >        tcc - Tiny C Compiler
> >
> > SYNOPSIS
> >        usage: tcc [options] [infile1 infile2...] [-run infile
> > args...]
> >
> > DESCRIPTION
> >        TCC options are a very much like gcc options. The main
> > difference is that TCC can also execute directly the
> >        resulting program and give it runtime arguments.
> >
> >        Here are some examples to understand the logic:
> >
> >        "tcc -run a.c"
> >            Compile a.c and execute it directly
> >
> >        "tcc -run a.c arg1"
> >            Compile a.c and execute it directly. arg1 is given as
> > first argument to the main() of a.c.
> >
> >        "tcc a.c -run b.c arg1"
> >            Compile a.c and b.c, link them together and execute them.
> > arg1 is given as first argument to the main()
> >            of the resulting program.
> >
> >
> Best wishes for 2025.
>
> PS my open source project is a GPL inference engine on
> https://github.com/RefPerSys/RefPerSys/
>
>
> --
> Basile STARYNKEVITCH           <bas...@starynkevitch.net>
> 8 rue de la Faïencerie
> 92340 Bourg-la-Reine,          France
> http://starynkevitch.net/Basile & https://github.com/bstarynk
>
>

Reply via email to