Re: Using gcc as a sort of scripting language.

2024-12-28 Thread carl hansen via Gcc
>>> cat e #!/bin/sh # # root -l -b < int main(void) { puts("Hello, world, you can ignore all that particle physics if you like."); printf("By the way, log(2025) is %lf\n",log(2025.)); printf("Here I have suppressed the banner\n"); return 0; } DOIT >>> ./e Hello, world, you can ignore al

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread carl hansen via Gcc
On Sat, Dec 28, 2024 at 2:48 PM Florian Weimer wrote: > [...] > > > Still it would be a nice touch if we could do > > #!/usr/bin/gcc -f > #include > int main() > { > puts("Hello, world"); > return 0; > } > re previously mentioned "root" >>> cat d #include int main(void) { puts("Hello, wo

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread Florian Weimer
* Jonathan Wakely via Gcc: > Here's a complete example: > > #!/bin/sh > set -e > out=$(mktemp /tmp/a.out.XX) > sed 1,5d "$0" | gcc -x c - -o "$out" > exec "$out" > > #include > int main() > { > puts("Hello, world"); > return 0; > } Or this, with accurate locations for diagnostics and arg

gcc-14-20241228 is now available

2024-12-28 Thread GCC Administrator via Gcc
Snapshot gcc-14-20241228 is now available on https://gcc.gnu.org/pub/gcc/snapshots/14-20241228/ and on various mirrors, see https://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 14 git branch with the following options: git://gcc.gnu.org/git/gcc.git branch

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread carl hansen via Gcc
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

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread Jonathan Wakely via Gcc
On Sat, 28 Dec 2024, 16:17 Jonathan Wakely, wrote: > > > On Sat, 28 Dec 2024, 15:26 Paul Smith via Gcc, wrote: > >> On Sat, 2024-12-28 at 09:00 -0600, Paul Markfort via Gcc wrote: >> > I realize that C is not a line oriented language and usually >> > completely ignores line termination character

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread Jonathan Wakely via Gcc
On Sat, 28 Dec 2024, 15:26 Paul Smith via Gcc, wrote: > On Sat, 2024-12-28 at 09:00 -0600, Paul Markfort via Gcc wrote: > > I realize that C is not a line oriented language and usually > > completely ignores line termination characters (so yes this is > > probably not a simple thing to do). > > Y

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread Paul Smith via Gcc
On Sat, 2024-12-28 at 09:00 -0600, Paul Markfort via Gcc wrote: > I realize that C is not a line oriented language and usually > completely ignores line termination characters (so yes this is > probably not a simple thing to do). You probably really want this capability added to the preprocessor,

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread Trampas Stern via Gcc
I had about the same thought 20 some years ago. I also wanted a more advanced preprocessor which had more scripting capabilities, with knowledge of the C lexical output. For example write a preprocessor script that would call a macro every time a function call was entered. I also always wondere

Re: Using gcc as a sort of scripting language.

2024-12-28 Thread Paul Markfort via Gcc
To be clear. I am not suggesting that Compilers like GCC be modified to act on the "#!", or even fully support it. Just that they be simply modified to ignore "#!" - on the first line (which should terminate with either a "/r" or "/n"). This allows the easy creation of scripts to handle an exec

Using gcc as a sort of scripting language.

2024-12-28 Thread Basile Starynkevitch
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. >