Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!news.cs.indiana.edu!arizona.edu!arizona!dave From: dave@cs.arizona.edu (Dave P. Schaumann) Newsgroups: comp.sys.amiga.programmer Subject: Manx/Lattice divergant behaviour Message-ID: <1001@caslon.cs.arizona.edu> Date: 4 Mar 91 00:04:25 GMT Organization: U of Arizona CS Dept, Tucson Lines: 41 Weather: sunny and warm! I've come across a curious incompatability between Manx and Lattice, and I'm hoping that someone can clear the air for me. Through the course of events, a friend and I both compiled the following code. I with Manx 3.6a, he with a Lattice compiler (sorry, don't know the version): /* Please excuse any typos; I typed this from memory. */ #include main() { FILE *my_win ; int c ; if( (my_win = fopen( "CON:10/10/100/200/C window", "a+" )) == NULL ) { puts( "Can't open window!" ) ; exit(1) ; } fprintf( my_win, "Some text\nAnd more text\n" ) ; while( (c = fgetc(my_win)) != EOF ) putc( c ) ; fclose( my_win ) ; puts( "Successful!" ) ; exit(0) ; } As you can see, this is a very straight forward, simple program that opens a window, prints some text, then enters a loop that reads characters from the program window and prints them to the shell window. My version of this works fine. The version compiled with Lattice sees EOF at fgetc() the first time it is executed, and exits immediately, whatever the input is. My question is: is the Lattice compiler broken/deficient, or is this an example of code with undefined behaviour? -- Dave Schaumann dave@cs.arizona.edu 'Dog Gang'! Where do they get off calling us the 'Dog Gang'? I'm beginning to think the party's over. I'm beginning to think maybe we don't need a dog. Or maybe we need a *new* dog. Or maybe we need a *cat*! - Amazing Stories