Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!tikal!amc!pilchuck!dataio!bright From: bright@Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c Subject: finding stray /* Message-ID: <1464@dataio.Data-IO.COM> Date: 18 Jan 88 19:00:04 GMT References: <38384@sun.uucp> <3573@sdcc6.ucsd.EDU> <434@drilex.UUCP> <7124@brl-smoke.ARPA> Reply-To: bright@dataio.UUCP (Walter Bright) Organization: Data I/O Corporation; Redmond, WA Lines: 25 In article <434@drilex.UUCP> dricej@drilex.UUCP (Craig Jackson) writes: > a = b/*c; >My friend spent two days looking for that one... You said that the compiler gave an 'unexpected EOF' error message. I'm surprised that more people don't use the binary search method of finding errors. In the above case, you copy your source file to test.c. Delete the bottom half of it. Recompile. If you get the error again, delete the bottom half of the remainder, etc., else copy the backup file to test.c and delete the bottom quarter, etc. You can easily see that the bug will be rapidly isolated. The binary search method is extremely useful when the compiler won't tell you what error the line was on, or if it crashes while compiling. I use this technique a lot when debugging my compiler :-). A more subtle bug I've had serious problems with is: a = b; /* some explanatory comment c = d; /* another comment */ Note the missing */ on the first comment, causing the c = d; to be ignored, which was very difficult and frustrating to find. Wasting my time on this is the primary reason why my compiler generates a warning if a /* is encountered within a comment, this stops the bug cold.