Ben Briggs
02-24-2001, 02:59 PM
Here's a Perl script I wrote to make compiling one file programs easier.
#!/usr/bin/perl
my $language = $ARGV[0];
my $file = $ARGV[1];
if($language eq ("C" or "c"))
{
system("/usr/bin/gcc $file.c -o $file");
} else
{
system("/usr/bin/g++ $file.cpp -o $file");
}
Usage is:
./compile C hello
./compile C++ hello
The first example will compile "hello.c" into "hello". And the second, "hello.cpp" into "hello".
This could obviously be expanded to include error detections, but I don't really have the initiative to do so (feel free if you do though).
[ 24 February 2001: Message edited by: Ben Briggs ]
#!/usr/bin/perl
my $language = $ARGV[0];
my $file = $ARGV[1];
if($language eq ("C" or "c"))
{
system("/usr/bin/gcc $file.c -o $file");
} else
{
system("/usr/bin/g++ $file.cpp -o $file");
}
Usage is:
./compile C hello
./compile C++ hello
The first example will compile "hello.c" into "hello". And the second, "hello.cpp" into "hello".
This could obviously be expanded to include error detections, but I don't really have the initiative to do so (feel free if you do though).
[ 24 February 2001: Message edited by: Ben Briggs ]