• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Const qualifier conversion warnings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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";
}


-- 

Michael Babin                           email@hidden

Order N Development, LLC       http://www.orderndev.com/

Goldfish Aquarium for Mac:     http://www.lifeglobe.com/product/index.php?pltid=2&ref=OrderNDev


 _______________________________________________
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

References: 
 >Re: Const qualifier conversion warnings (From: "Theodore H. Smith" <email@hidden>)

  • Prev by Date: Re: Using an Applescript xcode plugin to access data from the folders under Groups&Files
  • Next by Date: Re: Const qualifier conversion warnings
  • Previous by thread: Re: Const qualifier conversion warnings
  • Next by thread: Re: Const qualifier conversion warnings
  • Index(es):
    • Date
    • Thread