[LC++]scripting in C++

Torsten Rennett Torsten at Rennett.de
Wed Sep 29 23:42:02 UTC 2004


On Mittwoch, 29. September 2004 15:36, Jan Pfeifer wrote:
> lately i've been using more and more C++ even for
> small  programs for which i would previously use perl
> or python.
>
> so I'm trying to implement something to easy the
> process of compiling and using these C++ "scripts",
> and was wondering if i could have some comments/ideas
> from you on the subject -- whatever I do with it I'll
> publish later here as GNU software.
>
> my idea so far is very simple:
>
> - start the C++ "scripts" with a
>
>    #!/path/scriptc++ [linker options]
>
> - let's say I have a "filter.cc" program.
>
> - the "scriptc++" program tests if there is a
> ".filter.cc.compiled" file, and if not, or if
> "filter.cc" is newer, it tries to recompile and link
> "filter.cc" to ".filter.cc.compiled"
>
> - if compilation is successful, or if
> ".filter.cc.compiled" is newer than "filter.cc", just
> run it with the extra options passed to the execution
> of "filter.cc"

Your "scriptc++" is simply a Makefile after all ...

Create a 'run' target in your Makefile which depends on target 'all' (which 
builds everything as usual) and start the program in the action section.  
Now you can type 'make run' and the program will be build (if necassary) 
and started.

For various such "C++ scripts" you can use a pattern like this:
	alias prog1="(cd ~/scripts/prog1/; make run)"
	alias prog2="(cd ~/scripts/prog2/; make run)"
	...
Or:
	alias prog1="make -f ~/scripts/prog1/Makefile run"
	alias prog2="make -f ~/scripts/prog2/Makefile run"

Just an idea -- you have to work out the details ...

BTW: If you don't like compiling -- why don't you stay with Python?


Torsten

-- 
Ingenieurbuero RENNETT      -- innovative Software-Entwicklung --
Torsten Rennett                    http://www.RENNETT.de
Ludwig-Thoma-Weg 14         E-Mail:            Torsten at Rennett.de
D-85551 Heimstetten         Telefon:            +49 89 904 805 38




More information about the tuxCPProgramming mailing list