From: Matthew Kerwin Date: 2012-11-01T08:41:45+09:00 Subject: Re: bug?: local variable created in if modifier not available in modified expression Dude, did you seriously just write and compile a C program from within a ruby script? On 1 November 2012 05:11, Carlo E. Prelz wrote: > Subject: Re: bug?: local variable created in if modifier not available in modified expression > Date: Thu 01 Nov 12 03:57:47AM +0900 > > Quoting Robert Klemme (shortcutter@googlemail.com): > >> You mean like >> >> $ ruby -ce 'if a = 9 then puts 1 end' >> -e:1: warning: found = in conditional, should be == >> Syntax OK >> >> ? > > Yes, that's why I really like Ruby. But GCC can also be helpful in this: > > #!/usr/bin/env ruby > File::open('/tmp/test.c','w') do |f| > f.write <<-EOF > #include > int main(int argc,char *argv[]) > { > int i=1; > if(i=3) > printf("Bla bla\\n"); > > return 0; > } > EOF > end > system('gcc -o /tmp/test -Wall /tmp/test.c') > > gcc prints this warning: > > /tmp/test.c: In function ‘main’: > /tmp/test.c:5:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses] > > Carlo > > -- > * Se la Strada e la sua Virtu' non fossero state messe da parte, > * K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe > * di parlare tanto di amore e di rettitudine? (Chuang-Tzu) > -- Matthew Kerwin, B.Sc (CompSci) (Hons) http://matthew.kerwin.net.au/ ABN: 59-013-727-651 "You'll never find a programming language that frees you from the burden of clarifying your ideas." - xkcd