Martin Wells <warint@eircom.netwrites:
Quote:
When I have errors in a program, whether they be compiler errors,
linker errors, or if the program crashes when running, I have a list
of things I check for initially.
>
If I get an error for something undeclared, the first thing I do is go
through my header files and check that the inclusion-guard macro is
specific to that header file. For instance, if the header file is
called "data.h", I make sure the inclusion guard is "H__DATA" and not
something like "H__GUI". The reason I have to check for this is that I
commonly copy-paste inclusion guards from one header file to another.
[...]
If I found myself running into that kind of error frequently,
I'd (a) define a consistent convention for inclusion guard macro
names, where the macro name is mechanically derivable from the file
name, (b) write a tool that examines a header file (or optionally
traverses a directory tree containing header files) and reports any
inconsistencies, and (c) invoke the tool automatically, either as
part of the build process or as part of the process that packages
the software for release.
The directory traversal, of course, can't be done in portable
standard C. If I wanted to insist on implementing the tool in
portable standard C, I'd feed it a list of file names (though it
probably would still have to know how to extract the file name
portion of a full path). But in practice, I'd write it in Perl.
--
Keith Thompson (The_Other_Keith)
kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"