Path: utzoo!attcan!uunet!mcvax!botter.cs.vu.nl!star.cs.vu.nl!jos From: jos@cs.vu.nl (Jos Warmer) Newsgroups: comp.lang.c++ Subject: Re: C++ as a better C (fact or fiction)? Message-ID: <735@vlot.cs.vu.nl> Date: 20 May 88 07:44:02 GMT References: <6590041@hplsla.HP.COM> <706@vlot.cs.vu.nl> <456@polari.UUCP> Reply-To: jos@cs.vu.nl (Jos Warmer) Organization: VU Informatica, Amsterdam Lines: 71 In article <456@polari.UUCP> rlb@polari.UUCP (rlb) writes: >In article <706@vlot.cs.vu.nl>, jos@cs.vu.nl (Jos Warmer) writes: >> In article <6590041@hplsla.HP.COM> bobk@hplsla.HP.COM (Bob Kunz) writes: >> > >> >> I would advise using C++ to anyone. If not for its extra facilities, >> then at least for use as a MUCH better lint. >> >> Jos Warmer >> jos@cs.vu.nl > >I can't glean too much from the C++ book about what kinds of semantic checks >the compiler performs beyond type checking for expressions and function args >(and checking to see that all possible values are accounted for if you switch >on an enumeration). Doesn't lint provide type checking? What semantic checks >does C++ provide that exceed those of (Unix) lint? A comparison of features >would be most enlightening. > >Ron Burk I don't know all the differences, but generally the error-messages of C++ are much more informative then those from lint. Sometimes C++ finds more errors than lint. Furthermore lint gives too many useless messages, which makes it more difficult to find the messages that are important. Some examples to show you the flavor of messages from lint and C++: ========================================================================== In this example the message from C++ is much more informative: This happened to me yesterday, when I added the variable report to main(). I did not understand the message from cc (which was the same as lint), but after running C++ the mistake was clear. extern report(); main() { char* report = (char*)0; /* lots of code, so you don't see the declaration of report anymore */ report(); } lint: line 7: illegal function C++ : line 7: error: call of report; report is a char * ========================================================================== In this example the message from C++ is more informative: main() { char* s; int i = s; i = s; } lint: line 6: warning: illegal combination of pointer and integer, op = C++ : line 6: error: bad assignment type: int = char * ========================================================================== In this example the message from lint is useless, and the error that C++ found, was not detected by lint. int hello() { } lint: hello defined( x.c(2) ), but never used C++ : line 3: warning: no value returned from hello() ========================================================================== Jos Warmer jos@cs.vu.nl