This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix compilation error in i2c.cxx


On Fri, 2005-07-15 at 14:44 +0100, Bart Veer wrote:
> No. The actual bug is that the const should not be present. The
> cyg_i2c_bus* argument was originally const but this was later dropped,
> allowing the init fn to tweak the bus structure if necessary. The
> compiler version I was using at the time did not show this.

That's what I originally had -- but isn't NULL defined to be NULL no
matter what the pointer type is, so there is no need to manually
construct one for each particular pointer?

As I understand it the only time you might need to cast 0 for a null
pointer is when passing to a function where the compiler might not be
able to tell that it is a pointer context (e.g. variable argument lists
etc).

See, for example question 5.2 in the C language FAQ
http://www.faqs.org/faqs/C-faq/faq/

In any case, in my experience, you mostly just see function pointers
checked as

	if (op->func)
		(op->func)(arg)

with out the explicit compare against NULL (which happens to correspond
to 5.3 in the FAQ referenced above)...

Ian.
-- 
Ian Campbell, Senior Design Engineer
                                        Web: http://www.arcom.com
Arcom, Clifton Road,                    Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom       Phone:  +44 (0)1223 411 200


_____________________________________________________________________
The message in this transmission is sent in confidence for the attention of the addressee only and should not be disclosed to any other party. Unauthorised recipients are requested to preserve this confidentiality. Please advise the sender if the addressee is not resident at the receiving end.  Email to and from Arcom is automatically monitored for operational and lawful business reasons.

This message has been virus scanned by MessageLabs.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]