On Sunday, 19 February 2012 at 11:39:15 UTC, kraybourne wrote:
On 2/19/12 09:20 , Tyro[a.c.edwards] wrote:
Hi all,
I've just installed DMD 2.058 and attempted to compile a
little script
but was greeted with the following error:
gcc: Invalid argument
I used the .dmg installer from
http://www.dlang.org/download.html and
issued the command:
dmd average
Is there something I'm missing?
Thanks,
Andrew
Hi!
Could you try
dmd -v avarage
and tell us what comes out?
Also, how does avarage.d look? Also what does
uname -a
and
gcc --version
say? Also, just in case
which dmd
I made the mistake of assuming that gcc was automatically
installed in MAC OSX. After installing Xcode the problem went
away. To answer your questions though:
I'm using DMD version 2.058 for MAC OSX which I installed using
the .dmg package available at
"http://www.dlang.org/download.html".
"gcc --version" yields:
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc.
build 5658) (LLVM build 2336.9.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
"uname -a" yields:
Darwin Andrews-MacBook-Pro.local 11.3.0 Darwin Kernel Version
11.3.0: Thu Jan 12 18:47:41 PST 2012;
root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
the average program is as follows:
[code]
import std.stdio: stdin, writefln;
import std.conv: to;
void main(string[] args)
{
double sum = 0.0;
int cnt = 0;
foreach(line; stdin.byLine())
{
if(line.length)
{
sum += to!double (line);
cnt++;
}
}
double avg = sum / cnt;
writefln("Average is %.5f", avg);
}
[/code]
and I doubt you want me to put all of what "dmd -v" spits out for
this little script.
Thanks,
Andrew