Summary
Having the computer help you write and maintain your code is an essential facet of successful software development, and all good consultants will recommended that you follow suit. (Even if, sometimes, they forget to do so themselves ...)
Advertisement
I'm always banging on to clients about the importance of periodically running
code cleanup scripts over their code bases. One of the ones I recommended is
a trailing spaces remover, essential for C/C++ code because of the dangerous
effects it has on macros, and the concomitant difficulty of finding the
problem(s). And yesterday I got caught by just such a situation, having
failed to follow my own advice.
I'm in the process of adding some final touches to
Pantheios before its (highly overdue) final
1.0 non-beta release. One of these is adding some examples illustrating how
log statements may be targeted at certain
back-ends
by using the facilities for
"overloading" the severity levels, i.e. combining a bona-fide severity level
with additional information that may be used by a multiplexing/composite
back-end to route the statement to specific concrete back-end(s). The details
of what this all mean are somewhat
outside this discussion,
so suffice to say that it's the difference between, say
#include <pantheios/pan.hpp> // gives us the 'pan' namespace alias, for brevity
std::string general("general");
pantheios::log(pan::notice, "A statement of ", general, " importance");
#include <pantheios/pan.hpp> // gives us the 'pan' namespace alias, for brevity
int beidSpecial = . . . // The identifier of the specific back-end to which the statement will be targetted
std::string specific("specific");
pantheios::log(pan::notice(beidSpecial), "A statement of ", specific, " importance");
These facilities have been available for the library for a very long-time,
at least a year or so. But in writing the tutorial it became clear to me
that users who're
employing Pantheios in their C programs
are somewhat left
out in this regard. So I added the PANTHEIOS_MAKE_EXTENDED_SEVERITY()
macro"
I'm embarassed to admit that I had to sleep on this one before I had the mental
wherewithall to realise my mistake, and to cause the IDE to show spaces. In that
case the macro definition actually looks like the following (with the
symbol « used to represent a space):
So, take the advice, as I will myself try to do more thoroughly, and strip
those trailing spaces. I use a simple Perl script which is executed either
by find (on UNIX) or for on Windows.
I'd love to hear from anyone who's had similar experiences, especially where
they involve a little humbling stupidity. ;-)