Re: Const qualifier conversion warnings
Re: Const qualifier conversion warnings
- Subject: Re: Const qualifier conversion warnings
- From: Michael Babin <email@hidden>
- Date: Sun, 5 Jun 2005 18:30:19 -0500
On Jun 3, 2005, at 11:02 AM, Theodore H. Smith wrote: I should have been more specific, I already have "-Wno-cast-qual" on, which does actually remove most of these warnings. However some still remain.
warning: passing `const CString' as `this' argument of `CString CString::Left(long int)' discards qualifiers
BOOL CHTMLTagParser::UrlIsLocal(const CString &url) { CString proto = url.Left(4); proto.MakeLower(); return proto == "file"; }
"-Wno-cast-qual" has no effect on this warning.
As put forth by other respondents, I would also encourage any developer to resolve such warnings through proper use of the const attribute throughout their code base. However, if you're faced with a situation where that is not possible and you know the code you are calling will not alter it's objects/arguments, then you can always use const_cast to suppress the warning for a given call.
In this case:
BOOL CHTMLTagParser::UrlIsLocal(const CString &url) { CString proto = const_cast<CString &>(url).Left(4); proto.MakeLower(); return proto == "file"; }
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden