[ntp:questions] Unresolved Symbol

Richard B. Gilbert rgilbert88 at comcast.net
Tue Aug 21 13:25:54 UTC 2007


Maarten Wiltink wrote:
> "Aggie" <c.kevin.lam at gmail.com> wrote in message
> news:1187653764.667735.309710 at m37g2000prh.googlegroups.com...
> [...]
> 
>>Yes, I think you are right on the dereferncing a NULL part. Is there a
>>NUL?? is it the same as NULL??
>>Here's the line that gave me error:
>>    if ((pOpts->pzCurOpt != NULL) && (*pOpts->pzCurOpt != NUL))
> 
> 
> There is, and it itsn't. NULL is a pointer that doesn't point anywhere;
> NUL is the character at code point 0, used primarily to indicate the
> end of a string.
> 
> In that line of code, the pzCurOpt member of the pOpts struct is a
> pointer, apparently a pointer to char. The asterisk in the second term
> dereferences this pointer (that is, the pzCurOpt, not the pOpts), and
> so what the line does is first check that the pointer does in fact point
> somewhere, then check that it doesn't point to the end of the character
> string.
> 
> It is in all likelihood testing for an empty string, which would indicate
> that there are no more parameters (option strings). 
<snip>

This sounds like one of those cases where the author should really have 
included the comment /* Check for an empty string */.  It can be 
extremely difficult to understand someone else's code without a little 
help like that.  In a project of any size, it's usually essential to 
write understandable code.  If no one understands it, either someone is 
sure to break it or no one will ever touch it no matter how much a 
little maintenance is needed.

Yes, it takes a little effort, sometimes more than a little.  The value, 
if it's well done, is a large multiple of the cost.  The cost, if a 
piece of code is not well documented, can be as high as the need to 
rewrite from scratch or the complete inability to find and fix a serious 
problem!  Another manifestation is the extreme difficulty or complete 
inability to find a volunteer to maintain the code.





More information about the questions mailing list