Re: Code Comprehension



Mark P wrote:
Pascal Bourguignon wrote:
jmcgill <jmcgill@xxxxxxxxxxxxxxxxx> writes:

Pascal Bourguignon wrote:

if((string=NULL)||(bag==NULL)){return;} /* Actually no, my _strings_
are not NULL! */
Ouch. Now your "string" is :-)

Oops. I really should take the habit of writting the constant first...

(Actually, when I write C programs, I've got a rule in my makefiles to
detect this error).


Really? How do you do that?

I don't know how to do it with makefiles. If you use GCC the
--Wparentheses will make the compiler warn you about it. It will warn
you about some other things you might not care about too, and you may
intend to do it in some cases anyway. Some other compilers have
similar flags.

Some editors (such as GNU Emacs which I use) have an option to put an =
sign inside a comparison like statement in a bold font to make it stand
out.

As Pascal says if you write things in the form NULL ==string you can't
easily make this mistake. I think this, coupled with editor
highlighting, is a nicer solution than compiler warnings.

.



Relevant Pages

  • portable makefiles with f90 modules
    ... What is the current status of designing portable makefiles (on ... unix-like OSs and beyond) in large programming projects with f90 ... I'm assuming in a large project that source code is spread across ... files (or whatever they happen to be called by that compiler). ...
    (comp.lang.fortran)
  • SUMMARY: problem : install openssl
    ... Makefiles that use a syntax construction that confuses the compiler. ... Look for Makefiles where EXHEADER is not assigned a value: ... but it bombs out during make install and display ...
    (SunManagers)
  • Re: compiling VS6 C++ in VS2005 using a makefile
    ... using the VS2005 compiler) to produce two ATL COM servers. ... If you really want to stick with makefiles, ... IDE is able to take advantage of it by parallelizing some builds (at the ... ..dep files, generated by VS 6.0, for this. ...
    (microsoft.public.vc.language)
  • Re: XMLReader skip current element
    ... between statements, it's still syntactically invalid, but it recovers ... leaves off a semi-colon is that the end of the statement where the semi-colon was expected is flagged. ... Just as the compiler won't compile a file even though it could usually correctly infer the correct location of the semicolon, it's not really like the VS editor has judged the remainder of the file correct and accurate. ... Compilers, code editors, and XML editors alike can all make inferences about what the input data *should* look like, and try to produce correct behavior based on those inferences. ...
    (microsoft.public.dotnet.languages.csharp)
  • Compiling but not linking correctly
    ... makefiles and running their script from the cygwin shell (with the VC80 ... have all the object files I need for linking but somehow the compiler ... is not getting the correct instruction to fetch these object files. ... external symbols but do not know where these symbols are coming from. ...
    (microsoft.public.dotnet.framework)