Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I'm confused about some compiler warnings.
QtWS25 Last Chance

I'm confused about some compiler warnings.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by A Former User
    #1

    hi,

    my app utilize c & c++ std mixed to Qt c++ .... in some part of my app these generates some warnings do not understand by me..... I have a lot of these because I do a lot of repetitive use of the code structure ... the tree warning:

    double MainWindow::kTagx = 0;   /*static variable declaration*/
    
    kTagx = ui->le_xoff1->text().toDouble(false);  /*variable use*/
    
    /home/Qt/BC/mainwindow.cpp:7434: warning: converting 'false' to pointer type for argument 1 of 'double QString::toDouble(bool*) const' [-Wconversion-null]
         kTagx = ui->le_xoff1->text().toDouble(false); /*warning*/
                                                    ^
    
    ***********************************************************************************
    
    std::vector<BoxT> boxt;  /*struct vector declaration*/
    
    for ( int ibox = 0; ibox != boxt.size(); ibox++) /*usage vector.size value but c++ */
               {
    		......
    
    
    /home/Qt/BC/mainwindow.cpp:10035: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                for ( int ibox = 0; ibox != boxt.size(); ibox++)  /*warning but not in c++*/
                                                      ^
    
    
    *********************************************************************
    
    std::size_t read2; /*declare*/
    
    /home/Qt/BC/bth2.cpp:293: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while ((read2 = getline(&line2, &len2, file2)) != -1) { qDebug() << "nice stupid";} /*usage & warning .... but in c++ no warning*/
    

    I appreciate any suggest (link to study is ok ... an explanation would be an icing on the cake).

    regards
    Giorgio

    bkt

    mrjjM 1 Reply Last reply
    0
    • gfxxG gfxx

      hi,

      my app utilize c & c++ std mixed to Qt c++ .... in some part of my app these generates some warnings do not understand by me..... I have a lot of these because I do a lot of repetitive use of the code structure ... the tree warning:

      double MainWindow::kTagx = 0;   /*static variable declaration*/
      
      kTagx = ui->le_xoff1->text().toDouble(false);  /*variable use*/
      
      /home/Qt/BC/mainwindow.cpp:7434: warning: converting 'false' to pointer type for argument 1 of 'double QString::toDouble(bool*) const' [-Wconversion-null]
           kTagx = ui->le_xoff1->text().toDouble(false); /*warning*/
                                                      ^
      
      ***********************************************************************************
      
      std::vector<BoxT> boxt;  /*struct vector declaration*/
      
      for ( int ibox = 0; ibox != boxt.size(); ibox++) /*usage vector.size value but c++ */
                 {
      		......
      
      
      /home/Qt/BC/mainwindow.cpp:10035: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                  for ( int ibox = 0; ibox != boxt.size(); ibox++)  /*warning but not in c++*/
                                                        ^
      
      
      *********************************************************************
      
      std::size_t read2; /*declare*/
      
      /home/Qt/BC/bth2.cpp:293: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           while ((read2 = getline(&line2, &len2, file2)) != -1) { qDebug() << "nice stupid";} /*usage & warning .... but in c++ no warning*/
      

      I appreciate any suggest (link to study is ok ... an explanation would be an icing on the cake).

      regards
      Giorgio

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      @gfxx said in std c++ and QT some warning ...:

      Hi

      • converting 'false' to pointer type for argument 1 of 'double QString::toDouble(bool*)
        It expects a pointer type and tells you that false is not such type. C++ is not as relaxed as c with types.
        try NULL or nullptr
        http://en.cppreference.com/w/cpp/types/nullptr_t
        Its asks for a pointer to a bool so it can return convert status there.
        false is not a null pointer.
        Maybe you can even just leave it out.

      • comparison between signed and unsigned integer expressions [-Wsign-compare]
        I think its covered good here
        http://stackoverflow.com/questions/7984955/what-is-wrong-with-my-for-loops-i-get-warnings-comparison-between-signed-and-u

      1 Reply Last reply
      4
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @mrjj, if you don't care about the validity of the toDouble call then don't pass anything to it.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • gfxxG Offline
          gfxxG Offline
          gfxx
          wrote on last edited by
          #4

          Thanks at all I understand .... and solve.

          regards
          Giorgio

          bkt

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved