This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: need help on gfortran and C++
Hi Tobias,
2012/1/11 Tobias Burnus <burnus@net-b.de>:
>
> Reading the C99 standard, I had expected 0 and 1 and not 0 and -1 to be the
> "correct" result, but I think in terns of the Fortran standard, "-1" is also
> valid as it works with the accompanying C compiler of the same vendor.
>
> Tobias
If I understand it correctly, the C definition of true and false is:
0 is false and everything else is true, as exemplified by the output of
this program:
/* chk.c --
What is true and what is false in C?
*/
#include "stdlib.h"
#include "stdio.h"
int main( int argc, char *argv[] ) {
int i;
for (i = -5; i < 6; i ++) {
if ( i ) {
printf( "%d: true\n", i );
} else {
printf( "%d: false\n", i );
}
}
}
With gcc 4.6.1 I get:
-5: true
-4: true
-3: true
-2: true
-1: true
0: false
1: true
2: true
3: true
4: true
5: true
Regards,
Arjen