Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!ac From: ac@utgpu.UUCP Newsgroups: comp.sys.m6809 Subject: C bugs Message-ID: <1987May15.141952.4911@gpu.utcs.toronto.edu> Date: Fri, 15-May-87 14:19:52 EDT Article-I.D.: gpu.1987May15.141952.4911 Posted: Fri May 15 14:19:52 1987 Date-Received: Sat, 16-May-87 13:23:45 EDT Organization: University of Toronto Computing Services Lines: 38 Checksum: 55956 I wasted quite a bit of time the last few days trying to port a UUENCODE and UUDECODE program to OS9. It was a port of a port of a port but the version I finally got was for Mark William's C on an Atari ST. The really aggravating aspect of my problems was that they resulted from bugs I already knew about but I didn't think to check the source for these problems when I started having difficulties. Although these bugs have been reported before, I will describe them again in the hopes that others can avoid the problems I had. 1) Fopen normally opens the file specified in it's first argument according to the access specified in it's second argument. If the open fails for any reason, then NULL is returned, otherwise a valid file pointer is returned. If, however, the string which specifies the access includes an invalid letter, then the open will always "succeed", and a non-NULL file pointer is returned. This file pointer is in no way associated with the file you were trying to open! It appears to be STDIN or STDOUT. In my specific case the open was: fopen(argv[1],"rb") "B" is not valid under OS9 C so when the program went to read from my input file it hung waiting for input from the keyboard. 2) The code produced for comparisons of unsigned integers to literal zeros is incorrect. For example, if I is an unsigned int then the comparison i>0 will not work correctly. Code i!=0 instead. Avoid "<", ">" and combination of these with "=". 3) The final problem I had is one that I can't really put my finger on. I had added a bunch of diagnostic fprintf functions calls to my program. They were all very similar. I had just copied them to various points in the program to dump out the value of certain variables I was interested in. At one point I added a few more of these statements and started getting all sorts of "unresolved references" from the linker. The solution seemed to be to remove some of the calls but I can't for the life of me see how the last few added fprintf's were any different than the earlier one. Has anyone ever had any problems with unexplainable unresolved references? -- Name: Mark Acfield (University of Toronto Computing Services) Path: ihnp4!utgpu!ac Alias: ac@utoronto.bitnet