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.
So one could write C or C++ (or Fortran, etc) code and just run the source file 
to compile and run.

The Best way to make this possible is to set up the compiler to ignore "#!" if 
it is the first line.
Maybe a special pre-processor would work as well, but it is nice if one can 
send the unmodified source through the standard compilers (the edit and run 
process is a quick way to try out ideas before creating a full program).

This could encourage people to do this more often (increasing the utility of 
writing short compiled scripts) if one could do the below by simply starting 
the source file with:

#! /usr/bin/compile-and-run-file.sh -v


Currently, to do this (with C and C++) one needs to start their code similar to 
this (this works, I have tested it):


#if 0   /*              (first line is blank on purpose)
        #       Warning, the following will usually be run by sh (not bash, nor 
csh)
        #       If you make this file executable - it will be processed by the 
script below.
        compile-and-run-file.sh -v "${0}" "${@}"
        exit
        #       End of C comment        */
#endif





I have a complete example here (including the complile-and-run-file.sh script):
        http://www.paulfm.com/~paulfm/share/code/make-scratch/

Note: I am not a very good C/C++ programmer, so I don't pretend to have the 
best answer (this is just an example of one way to do this).


Thanks.


--
--------------------------------------------------------
The views and opinions expressed above are strictly
those of the author(s).  The content of this message has
not been reviewed nor approved by any entity whatsoever.
--------------------------------------------------------
Paul FM         Info: http://paulfm.com/~paulfm/
--------------------------------------------------------

Reply via email to