Results 1 to 4 of 4

Thread: warning: ISO C++ says that these are ambiguous, even though the worst conversion for

  1. #1
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default warning: ISO C++ says that these are ambiguous, even though the worst conversion for

    The complete warning message is : warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
    candidate 1: bool QByteRef:perator==(char) const
    candidate 2: operator==(int, int) <built-in>

    which refers to the following code
    :
    Qt Code:
    1. if (receivedMessage[0] == 0x0a)
    To copy to clipboard, switch view to plain text mode 


    Is there a better way to write this code to get rid of this warning? Thanks for any help.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: warning: ISO C++ says that these are ambiguous, even though the worst conversion

    The message arises because the constant is an int, not a char.
    Qt Code:
    1. if (receivedMessage[0] == '\x0a')
    2. if (receivedMessage[0] == char(0x0a))
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    Ferric (16th November 2011)

  4. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: warning: ISO C++ says that these are ambiguous, even though the worst conversion

    Qt Code:
    1. if(receivedMessage.at(0) == 0x0a)
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Santosh Reddy for this useful post:

    Ferric (16th November 2011)

  6. #4
    Join Date
    Dec 2009
    Location
    New Zealand
    Posts
    54
    Thanks
    23
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: warning: ISO C++ says that these are ambiguous, even though the worst conversion

    All of the above seem to work, Thanks!

Similar Threads

  1. How to avoid "warning: deprecated conversion from"?
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 18th January 2011, 15:11
  2. ambiguous documentation and behavior of QTcpSocket
    By moviemax in forum General Programming
    Replies: 1
    Last Post: 4th June 2010, 23:11
  3. ambiguous connect()
    By Cruz in forum Qt Programming
    Replies: 2
    Last Post: 27th August 2009, 11:35
  4. `QObject' is an ambiguous base of `ClientThread'
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2006, 13:17
  5. ambiguous call to overloaded function
    By :db:sStrong in forum Qt Programming
    Replies: 18
    Last Post: 10th February 2006, 09:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.