Mail Archives: djgpp/1999/03/01/09:27:09
Carlos Giani_AEN2003 (M2003) writes:
> Here's an example program:
>
> #include <stdio.h>
> #include <conio.h>
> int main(void)
> {
> int x;
> int y;
>
> x = 0;
>
> y = (x) ? 1 : 2; /* y will ALWAYS be 1 (this is the BUG!) */
>
> printf("%i\n",y);
>
> getch();
> }
>
> I use RHIDE and GCC 2.8.1
This works correctly for me. Using gcc 2.8.1, I compile it with the
options "gcc -O3 -Wall test.c -o test.exe", which gives the warning:
test.c: In function `main':
test.c:12: warning: control reaches end of non-void function
You should fix that by returning something sensible (eg. zero) at
the end of main(), but that is just a detail. Apart from this,
your code works exactly as it should, and prints 2. What options
do you use to compile it? Exactly what compiler packages did you
install?
Shawn Hargreaves.
- Raw text -