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. How to remove incorrect warning?
QtWS25 Last Chance

How to remove incorrect warning?

Scheduled Pinned Locked Moved Solved General and Desktop
29 Posts 6 Posters 5.4k 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.
  • E Offline
    E Offline
    Engelard
    wrote on 2 Dec 2018, 23:31 last edited by Engelard 12 Mar 2018, 09:47
    #1

    In new version 5.12 appears much better warning functionality, but how can i remove particular warnings which inappropriate? I fixed all the warnings, but last one i can't fix because it in WinAPI libraries:

    0_1543793467765_sdfkldsffds.jpg

    J 1 Reply Last reply 3 Dec 2018, 08:55
    0
    • J JKSH
      4 Dec 2018, 01:56

      @Engelard said in How to remove incorrect warning?:

      My solution with LPDWORD more correct simply because function GetExitCodeProcess demand LPDWORD.

      It is correct to pass an LPDWORD parameter into GetExitCodeProcess().

      It is wrong to use == or != to compare two LPDWORD variables because it is wrong to use == or != to compare pointers. Do you agree?

      E Offline
      E Offline
      Engelard
      wrote on 4 Dec 2018, 14:20 last edited by Engelard 12 Apr 2018, 15:01
      #27

      @JKSH said in How to remove incorrect warning?:

      It is wrong to use == or != to compare two LPDWORD variables because it is wrong to use == or != to compare pointers. Do you agree?

      Honestly, i don't know about comparing pointers, but it was in example to GetExitCodeProcess.

      UPDATE:

      Oh, now i get it. Was wrong example i found. So here is final code, do it better probably impossible:

      0_1543934596938_gggggggggg.jpg

      Tnx everyone for helping clarify those things.

      J 1 Reply Last reply 5 Dec 2018, 02:40
      0
      • E Offline
        E Offline
        Engelard
        wrote on 3 Dec 2018, 04:03 last edited by
        #2

        Or what should i do with such blocks which have alot of binary operations(all of them are correct and works exactly as they should). On screen array of unsigned chars:

        0_1543809820848_needededint.jpg

        J 1 Reply Last reply 3 Dec 2018, 05:22
        0
        • E Engelard
          3 Dec 2018, 04:03

          Or what should i do with such blocks which have alot of binary operations(all of them are correct and works exactly as they should). On screen array of unsigned chars:

          0_1543809820848_needededint.jpg

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 3 Dec 2018, 05:22 last edited by
          #3

          @Engelard These are not incorrect warnings.
          You should fix the issues in your code instead of suppressing warnings.
          If you're converting, for example, int to char you should do it explicitly and think about possible issues.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          E 1 Reply Last reply 3 Dec 2018, 09:44
          4
          • E Engelard
            2 Dec 2018, 23:31

            In new version 5.12 appears much better warning functionality, but how can i remove particular warnings which inappropriate? I fixed all the warnings, but last one i can't fix because it in WinAPI libraries:

            0_1543793467765_sdfkldsffds.jpg

            J Offline
            J Offline
            JKSH
            Moderators
            wrote on 3 Dec 2018, 08:55 last edited by
            #4

            @Engelard said in How to remove incorrect warning?:

            I fixed all the warnings

            👍

            last one i can't fix because it in WinAPI libraries:

            Yes, this warning is caused by winnt.h so you can't fix that one.

            Or this one. arg1 - is digital number from user which i should convert to single byte(unsigned char), toUint is exactly what i needed, to uChar does'nt exist, but it gives me that warning..

            ...

            Or what should i do with such blocks which have alot of binary operations(all of them are correct and works exactly as they should). On screen array of unsigned chars:

            These warn you about implicit conversion. To remove the warning, use static_cast<> to do explicit conversion.

            In new version 5.12 appears much better warning functionality,

            The new features are part of the Clang Code Model: https://blog.qt.io/blog/2018/06/05/qt-creators-clang-code-model/

            how can i remove particular warnings which inappropriate?

            https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            E 1 Reply Last reply 3 Dec 2018, 09:59
            6
            • J jsulm
              3 Dec 2018, 05:22

              @Engelard These are not incorrect warnings.
              You should fix the issues in your code instead of suppressing warnings.
              If you're converting, for example, int to char you should do it explicitly and think about possible issues.

              E Offline
              E Offline
              Engelard
              wrote on 3 Dec 2018, 09:44 last edited by
              #5
              This post is deleted!
              1 Reply Last reply
              0
              • J JKSH
                3 Dec 2018, 08:55

                @Engelard said in How to remove incorrect warning?:

                I fixed all the warnings

                👍

                last one i can't fix because it in WinAPI libraries:

                Yes, this warning is caused by winnt.h so you can't fix that one.

                Or this one. arg1 - is digital number from user which i should convert to single byte(unsigned char), toUint is exactly what i needed, to uChar does'nt exist, but it gives me that warning..

                ...

                Or what should i do with such blocks which have alot of binary operations(all of them are correct and works exactly as they should). On screen array of unsigned chars:

                These warn you about implicit conversion. To remove the warning, use static_cast<> to do explicit conversion.

                In new version 5.12 appears much better warning functionality,

                The new features are part of the Clang Code Model: https://blog.qt.io/blog/2018/06/05/qt-creators-clang-code-model/

                how can i remove particular warnings which inappropriate?

                https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

                E Offline
                E Offline
                Engelard
                wrote on 3 Dec 2018, 09:59 last edited by
                #6

                @JKSH said in How to remove incorrect warning?:

                https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

                Tnx. But it will remove not particular warning(like first which from WINAPI), but whole kind - use of old-style cast which i don't want to, that warning is useful, and it not worthing remove all of them just because of single mistake of QCreator.

                Topic still actual.

                K 1 Reply Last reply 3 Dec 2018, 10:06
                0
                • E Engelard
                  3 Dec 2018, 09:59

                  @JKSH said in How to remove incorrect warning?:

                  https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

                  Tnx. But it will remove not particular warning(like first which from WINAPI), but whole kind - use of old-style cast which i don't want to, that warning is useful, and it not worthing remove all of them just because of single mistake of QCreator.

                  Topic still actual.

                  K Offline
                  K Offline
                  koahnig
                  wrote on 3 Dec 2018, 10:06 last edited by
                  #7

                  @Engelard said in How to remove incorrect warning?:

                  @JKSH said in How to remove incorrect warning?:

                  https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

                  Tnx. But it will remove not particular warning(like first which from WINAPI), but whole kind - use of old-style cast which i don't want to, that warning is useful, and it not worthing remove all of them just because of single mistake of QCreator.

                  Topic still actual.

                  Why is this a mistake or error of Qt creator?

                  Is the warning completely wrong or is it because of an include, which is not part of Qt?

                  Vote the answer(s) that helped you to solve your issue(s)

                  E 1 Reply Last reply 3 Dec 2018, 11:04
                  3
                  • K koahnig
                    3 Dec 2018, 10:06

                    @Engelard said in How to remove incorrect warning?:

                    @JKSH said in How to remove incorrect warning?:

                    https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

                    Tnx. But it will remove not particular warning(like first which from WINAPI), but whole kind - use of old-style cast which i don't want to, that warning is useful, and it not worthing remove all of them just because of single mistake of QCreator.

                    Topic still actual.

                    Why is this a mistake or error of Qt creator?

                    Is the warning completely wrong or is it because of an include, which is not part of Qt?

                    E Offline
                    E Offline
                    Engelard
                    wrote on 3 Dec 2018, 11:04 last edited by
                    #8

                    @koahnig said in How to remove incorrect warning?:

                    Is the warning completely wrong or is it because of an include, which is not part of Qt?

                    Probably because not part of my project i'd say. Warning which user can't fix is wrong warning.

                    J.HilkJ 1 Reply Last reply 3 Dec 2018, 11:08
                    0
                    • E Engelard
                      3 Dec 2018, 11:04

                      @koahnig said in How to remove incorrect warning?:

                      Is the warning completely wrong or is it because of an include, which is not part of Qt?

                      Probably because not part of my project i'd say. Warning which user can't fix is wrong warning.

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on 3 Dec 2018, 11:08 last edited by
                      #9

                      @Engelard are you sure the warning doesn't come from your code, where you compare LPDWORD with LPCVOID that seems like an implicit - presumably oldstyle - cast so that a comparison can happen.


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      E 1 Reply Last reply 3 Dec 2018, 11:12
                      2
                      • J.HilkJ J.Hilk
                        3 Dec 2018, 11:08

                        @Engelard are you sure the warning doesn't come from your code, where you compare LPDWORD with LPCVOID that seems like an implicit - presumably oldstyle - cast so that a comparison can happen.

                        E Offline
                        E Offline
                        Engelard
                        wrote on 3 Dec 2018, 11:12 last edited by Engelard 12 Mar 2018, 11:21
                        #10

                        @J.Hilk Nope, changed conversion type after your post, still same warn, at least because underscored with yellow exactly WINapi keyword(take a look at screenshot). Plus - it tells that warning exactly because of keyword STILL_ACTIVE

                        @JKSH said in How to remove incorrect warning?:

                        https://stackoverflow.com/questions/51612041/disable-a-specific-warning-in-qtcreator

                        I can't get it, how to remove even whole kind of warnings? For example i want remove "warning: implicit conversion changes signedness:" But can't find anywhere proper code for it. Searched in docs, found macro like -Wpointer-sign (C and Objective-C only) But it seems not working, or it's just macro for another warning type, not for my.

                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          Engelard
                          wrote on 3 Dec 2018, 19:38 last edited by
                          #11

                          I noticed that hint(right-top corner) -Wsign-conversion , added it to my Code Model, but error still exist... what am i doing wrong?

                          K 1 Reply Last reply 3 Dec 2018, 19:41
                          0
                          • E Engelard
                            3 Dec 2018, 19:38

                            I noticed that hint(right-top corner) -Wsign-conversion , added it to my Code Model, but error still exist... what am i doing wrong?

                            K Offline
                            K Offline
                            koahnig
                            wrote on 3 Dec 2018, 19:41 last edited by
                            #12

                            @Engelard

                            -Wno-sign-conversion

                            Vote the answer(s) that helped you to solve your issue(s)

                            E 1 Reply Last reply 3 Dec 2018, 19:46
                            1
                            • K koahnig
                              3 Dec 2018, 19:41

                              @Engelard

                              -Wno-sign-conversion

                              E Offline
                              E Offline
                              Engelard
                              wrote on 3 Dec 2018, 19:46 last edited by
                              #13

                              @koahnig That is it!. Tnx. only one thing left - individually handle that warning from WINAPI...

                              K 1 Reply Last reply 3 Dec 2018, 19:55
                              0
                              • E Engelard
                                3 Dec 2018, 19:46

                                @koahnig That is it!. Tnx. only one thing left - individually handle that warning from WINAPI...

                                K Offline
                                K Offline
                                koahnig
                                wrote on 3 Dec 2018, 19:55 last edited by
                                #14

                                @Engelard

                                It is obvious IMHO that you have to add a "no-" for warnings you do not like from code model as it is -Wsign-conversion.

                                Vote the answer(s) that helped you to solve your issue(s)

                                E 1 Reply Last reply 3 Dec 2018, 20:05
                                0
                                • K koahnig
                                  3 Dec 2018, 19:55

                                  @Engelard

                                  It is obvious IMHO that you have to add a "no-" for warnings you do not like from code model as it is -Wsign-conversion.

                                  E Offline
                                  E Offline
                                  Engelard
                                  wrote on 3 Dec 2018, 20:05 last edited by
                                  #15

                                  @koahnig yep. I guessed that after your example.

                                  kshegunovK 1 Reply Last reply 3 Dec 2018, 20:10
                                  0
                                  • E Engelard
                                    3 Dec 2018, 20:05

                                    @koahnig yep. I guessed that after your example.

                                    kshegunovK Offline
                                    kshegunovK Offline
                                    kshegunov
                                    Moderators
                                    wrote on 3 Dec 2018, 20:10 last edited by
                                    #16

                                    Your code is wrong, so that warning is very useful in fact.

                                    if (exitCode != reinterpret_cast<LPCVOID>(...))
                                    

                                    is nonsense. You can't (or rather shouldn't) cast integers to const void * ...
                                    What you should do instead is something like this:

                                    if (*exitCode != STILL_ACTIVE) { /* do something */ }
                                    

                                    reinterpret_cast is the one sure way to blow your leg off while trying to shoot yourself in the foot.

                                    Read and abide by the Qt Code of Conduct

                                    E 1 Reply Last reply 3 Dec 2018, 20:18
                                    2
                                    • E Offline
                                      E Offline
                                      Engelard
                                      wrote on 3 Dec 2018, 20:12 last edited by
                                      #17
                                      This post is deleted!
                                      kshegunovK 1 Reply Last reply 3 Dec 2018, 20:13
                                      -1
                                      • E Engelard
                                        3 Dec 2018, 20:12

                                        This post is deleted!

                                        kshegunovK Offline
                                        kshegunovK Offline
                                        kshegunov
                                        Moderators
                                        wrote on 3 Dec 2018, 20:13 last edited by
                                        #18

                                        I can guarantee you you're never going to enter that branch. You're playing with fire. See my previous comment.

                                        Read and abide by the Qt Code of Conduct

                                        1 Reply Last reply
                                        0
                                        • kshegunovK kshegunov
                                          3 Dec 2018, 20:10

                                          Your code is wrong, so that warning is very useful in fact.

                                          if (exitCode != reinterpret_cast<LPCVOID>(...))
                                          

                                          is nonsense. You can't (or rather shouldn't) cast integers to const void * ...
                                          What you should do instead is something like this:

                                          if (*exitCode != STILL_ACTIVE) { /* do something */ }
                                          

                                          reinterpret_cast is the one sure way to blow your leg off while trying to shoot yourself in the foot.

                                          E Offline
                                          E Offline
                                          Engelard
                                          wrote on 3 Dec 2018, 20:18 last edited by
                                          #19

                                          @kshegunov said in How to remove incorrect warning?:

                                          What you should do instead is something like this:
                                          if (exitCode != STILL_ACTIVE) { / do something */ }

                                          Nope

                                          Will be more warnings(first one actually, no matter what code you'll make, it screaming because of definition inside windows libraries). Your proposal:
                                          0_1543868290472_hhhhh.jpg

                                          kshegunovK 1 Reply Last reply 3 Dec 2018, 20:23
                                          0
                                          • E Engelard
                                            3 Dec 2018, 20:18

                                            @kshegunov said in How to remove incorrect warning?:

                                            What you should do instead is something like this:
                                            if (exitCode != STILL_ACTIVE) { / do something */ }

                                            Nope

                                            Will be more warnings(first one actually, no matter what code you'll make, it screaming because of definition inside windows libraries). Your proposal:
                                            0_1543868290472_hhhhh.jpg

                                            kshegunovK Offline
                                            kshegunovK Offline
                                            kshegunov
                                            Moderators
                                            wrote on 3 Dec 2018, 20:23 last edited by
                                            #20

                                            Don't make me smack you; I've been doing programming all my life.

                                            Firstly, the warning is the least of your problems. You're giving a pointer to uninitialized memory block (i.e. null) as an output parameter. Then you're casting an integer to a memory address?
                                            How it works is as follows:

                                            DWORD exitCode;
                                            GetExitProces(..., &exitCode);
                                            if (exitCode != STILL_ACTIVE)  { /* blabla */ }
                                            

                                            If the warning is the only thing that bothers you, then cast the macro to the proper type explicitly:

                                            if (exitCode != static_cast<DWORD>(STILL_ACTIVE))  { /* more blabla */ }
                                            

                                            Read and abide by the Qt Code of Conduct

                                            E 1 Reply Last reply 3 Dec 2018, 20:37
                                            1

                                            2/29

                                            3 Dec 2018, 04:03

                                            topic:navigator.unread, 27
                                            • Login

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