Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to avoid warning LNK4224: /COMMENT is no longer supported

How to avoid warning LNK4224: /COMMENT is no longer supported

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
17 Posts 8 Posters 0 Views 1 Watching
  • 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.
  • C Cedric Moonen

    Same as here[^]


    Cédric Moonen Software developer
    Charting control [v1.2]

    P Offline
    P Offline
    Paresh Chitte
    wrote on last edited by
    #7

    You are correct Cedric. :) As per MSDN[^] "Treats all compiler warnings as errors. For a new project, it may be best to use /WX in all compilations; resolving all warnings will ensure the fewest possible hard-to-find code defects." Regards, Paresh.

    M 1 Reply Last reply
    0
    • C Cedric Moonen

      That's not really removing the source of the warning but just make it silent. Which is not really a good solution. Sure, you could do that with all your warnings but it is maybe better to find way it is complaining.


      Cédric Moonen Software developer
      Charting control [v1.2]

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #8

      But there are some times that the warnings are not relevant or don't matter, due to the code. I.E. In the functions I added to the smartlist in my article: warning C4181: Auf Referenztyp angewendeter Qualifizierer wird ignoriert // In reference type the used qualifier will be ignored REASON: BOOL FindAndRemoveElement(const ARG_TYPE searchValue); warning C4018: '<=' : Conflict between signed and unsigned REASON: if (pInfo->m_nCurPage <= (nInPages + (1 * (m_nPrintSel & PRALL)))) warning C4244: 'argument' : Conversion of 'const double' in 'int', possible loose of data REASON: cbmGraphic.CreateCompatibleBitmap (pDC, 4 * GWIDTH, -4 * GHEIGHT); SOLUTION: casting to the correct typ, but dont needed, but in this case I wanna lose the decimals by truncating and the constants must be float/double for other places to be used. And I have about 90 times this warning warning C4308: Negative Ganzzahlkonstante in vorzeichenlosen Typ konvertiert //Conversion of negative integer constant in unsigned type REASON: file->Seek (-3 * sizeof (BYTE), CFile::current); So I use #pragma warning(disable:4244) #pragma warning(disable:4018) #pragma warning(disable:4181) and from 116 warnings I go to just 1 of them

      Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

      C D 2 Replies Last reply
      0
      • N Nelek

        But there are some times that the warnings are not relevant or don't matter, due to the code. I.E. In the functions I added to the smartlist in my article: warning C4181: Auf Referenztyp angewendeter Qualifizierer wird ignoriert // In reference type the used qualifier will be ignored REASON: BOOL FindAndRemoveElement(const ARG_TYPE searchValue); warning C4018: '<=' : Conflict between signed and unsigned REASON: if (pInfo->m_nCurPage <= (nInPages + (1 * (m_nPrintSel & PRALL)))) warning C4244: 'argument' : Conversion of 'const double' in 'int', possible loose of data REASON: cbmGraphic.CreateCompatibleBitmap (pDC, 4 * GWIDTH, -4 * GHEIGHT); SOLUTION: casting to the correct typ, but dont needed, but in this case I wanna lose the decimals by truncating and the constants must be float/double for other places to be used. And I have about 90 times this warning warning C4308: Negative Ganzzahlkonstante in vorzeichenlosen Typ konvertiert //Conversion of negative integer constant in unsigned type REASON: file->Seek (-3 * sizeof (BYTE), CFile::current); So I use #pragma warning(disable:4244) #pragma warning(disable:4018) #pragma warning(disable:4181) and from 116 warnings I go to just 1 of them

        Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #9

        I think it is bad because you can miss important warnings (things that you didn't thought about). You should get rid of the warnings instead of silenting them. I only disable them on some rare occasions. C4181: why do you put the const keyword then ? If it will be ignored ? It let you think that it is used but it isn't so it can lead to confusion. Why don't you just remove it ? This will lead to the same result without warning. C4018: why do you mix signed and unsigned ? That probably results to a bad design. They don't have the same range so if you start with a signed number, stick to it. On some rare occasion you will need to mix them, but then use an explicit cast. C4244:

        Nelek wrote:

        SOLUTION: casting to the correct typ, but dont needed, but in this case I wanna lose the decimals by truncating and the constants must be float/double for other places to be used. And I have about 90 times this warning

        Cast the complete block: (int)(4*GWIDTH)

        Nelek wrote:

        warning C4308: Negative Ganzzahlkonstante in vorzeichenlosen Typ konvertiert //Conversion of negative integer constant in unsigned type REASON: file->Seek (-3 * sizeof (BYTE), CFile::current);

        That's typically one of the warning you shouldn't neglect, because your code is wrong. The warning tells you that it converts the -3 to an unsigned, so the result won't be what you expect. It does that because sizeof returns an unsigned type and so, when doing the multiplication your compiler will convert the -3 to unsigned type so that it can multiply both operands.


        Cédric Moonen Software developer
        Charting control [v1.2]

        N 1 Reply Last reply
        0
        • P Paresh Chitte

          You are correct Cedric. :) As per MSDN[^] "Treats all compiler warnings as errors. For a new project, it may be best to use /WX in all compilations; resolving all warnings will ensure the fewest possible hard-to-find code defects." Regards, Paresh.

          M Offline
          M Offline
          mohindar_kks
          wrote on last edited by
          #10

          How to remove the /COMMENT directory from the project settings

          1 Reply Last reply
          0
          • C Cedric Moonen

            That's not really removing the source of the warning but just make it silent. Which is not really a good solution. Sure, you could do that with all your warnings but it is maybe better to find way it is complaining.


            Cédric Moonen Software developer
            Charting control [v1.2]

            B Offline
            B Offline
            bob16972
            wrote on last edited by
            #11

            It makes sense from time to time. Just don't abuse it. It just that, a warning (not an error). The programmer goes and scrutinizes the code and makes a decision. If they deem the existing code sound, then disabling the warning for that specific chunk of code makes perfect sense. Make sure to turn the warning back on after the section of code in question that has been deemed by the programmer as fine. That way every future warning will need to be scrutinized by the programmer and they get to decide if it's a false alram or not. #pragma warning (disable: XXXX) // Some code that is deemed OK after reviewing warnings #pragma warning (default: XXXX)

            N 1 Reply Last reply
            0
            • C Cedric Moonen

              I think it is bad because you can miss important warnings (things that you didn't thought about). You should get rid of the warnings instead of silenting them. I only disable them on some rare occasions. C4181: why do you put the const keyword then ? If it will be ignored ? It let you think that it is used but it isn't so it can lead to confusion. Why don't you just remove it ? This will lead to the same result without warning. C4018: why do you mix signed and unsigned ? That probably results to a bad design. They don't have the same range so if you start with a signed number, stick to it. On some rare occasion you will need to mix them, but then use an explicit cast. C4244:

              Nelek wrote:

              SOLUTION: casting to the correct typ, but dont needed, but in this case I wanna lose the decimals by truncating and the constants must be float/double for other places to be used. And I have about 90 times this warning

              Cast the complete block: (int)(4*GWIDTH)

              Nelek wrote:

              warning C4308: Negative Ganzzahlkonstante in vorzeichenlosen Typ konvertiert //Conversion of negative integer constant in unsigned type REASON: file->Seek (-3 * sizeof (BYTE), CFile::current);

              That's typically one of the warning you shouldn't neglect, because your code is wrong. The warning tells you that it converts the -3 to an unsigned, so the result won't be what you expect. It does that because sizeof returns an unsigned type and so, when doing the multiplication your compiler will convert the -3 to unsigned type so that it can multiply both operands.


              Cédric Moonen Software developer
              Charting control [v1.2]

              N Offline
              N Offline
              Nelek
              wrote on last edited by
              #12

              Thanks for your answer. C4181: I didn't know that it would be ignored. I put that in const to avoid changes in the function by error, but if it is ignored... then it is useless. Erased and warnings away. C4018: casted in the places, warnings away C4244: casted in the places, change the return in a function and the warnings away C4308: changed to file->Seek (((UINT) -3) * sizeof (BYTE), CFile::current); is that correct? I want to go back in 3 bytes to reread the last block because it contains particular info that i need to start the next block

              Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

              D 1 Reply Last reply
              0
              • B bob16972

                It makes sense from time to time. Just don't abuse it. It just that, a warning (not an error). The programmer goes and scrutinizes the code and makes a decision. If they deem the existing code sound, then disabling the warning for that specific chunk of code makes perfect sense. Make sure to turn the warning back on after the section of code in question that has been deemed by the programmer as fine. That way every future warning will need to be scrutinized by the programmer and they get to decide if it's a false alram or not. #pragma warning (disable: XXXX) // Some code that is deemed OK after reviewing warnings #pragma warning (default: XXXX)

                N Offline
                N Offline
                Nelek
                wrote on last edited by
                #13

                I didn't know the how to enable them another time, thanks or the tip

                Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                1 Reply Last reply
                0
                • N Nelek

                  But there are some times that the warnings are not relevant or don't matter, due to the code. I.E. In the functions I added to the smartlist in my article: warning C4181: Auf Referenztyp angewendeter Qualifizierer wird ignoriert // In reference type the used qualifier will be ignored REASON: BOOL FindAndRemoveElement(const ARG_TYPE searchValue); warning C4018: '<=' : Conflict between signed and unsigned REASON: if (pInfo->m_nCurPage <= (nInPages + (1 * (m_nPrintSel & PRALL)))) warning C4244: 'argument' : Conversion of 'const double' in 'int', possible loose of data REASON: cbmGraphic.CreateCompatibleBitmap (pDC, 4 * GWIDTH, -4 * GHEIGHT); SOLUTION: casting to the correct typ, but dont needed, but in this case I wanna lose the decimals by truncating and the constants must be float/double for other places to be used. And I have about 90 times this warning warning C4308: Negative Ganzzahlkonstante in vorzeichenlosen Typ konvertiert //Conversion of negative integer constant in unsigned type REASON: file->Seek (-3 * sizeof (BYTE), CFile::current); So I use #pragma warning(disable:4244) #pragma warning(disable:4018) #pragma warning(disable:4181) and from 116 warnings I go to just 1 of them

                  Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #14

                  Nelek wrote:

                  But there are some times that the warnings are not relevant or don't matter, due to the code.

                  Compiler warnings are always relevant, else they would not exist. :rolleyes:


                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  N 1 Reply Last reply
                  0
                  • D David Crow

                    Nelek wrote:

                    But there are some times that the warnings are not relevant or don't matter, due to the code.

                    Compiler warnings are always relevant, else they would not exist. :rolleyes:


                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    N Offline
                    N Offline
                    Nelek
                    wrote on last edited by
                    #15

                    You are right... I wrote it in a false way. :~

                    Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                    1 Reply Last reply
                    0
                    • N Nelek

                      Thanks for your answer. C4181: I didn't know that it would be ignored. I put that in const to avoid changes in the function by error, but if it is ignored... then it is useless. Erased and warnings away. C4018: casted in the places, warnings away C4244: casted in the places, change the return in a function and the warnings away C4308: changed to file->Seek (((UINT) -3) * sizeof (BYTE), CFile::current); is that correct? I want to go back in 3 bytes to reread the last block because it contains particular info that i need to start the next block

                      Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                      D Offline
                      D Offline
                      DoomedOne
                      wrote on last edited by
                      #16

                      Nelek wrote:

                      C4308: changed to file->Seek (((UINT) -3) * sizeof (BYTE), CFile::current); is that correct? I want to go back in 3 bytes to reread the last block because it contains particular info that i need to start the next block

                      Hi, in this case, the ((UINT)-3) will be converted to 3, advansing the position in the file instead of going back, the cast should be in the sizeof : file->Seek (-3 * (long)sizeof(BYTE), CFile::current);

                      N 1 Reply Last reply
                      0
                      • D DoomedOne

                        Nelek wrote:

                        C4308: changed to file->Seek (((UINT) -3) * sizeof (BYTE), CFile::current); is that correct? I want to go back in 3 bytes to reread the last block because it contains particular info that i need to start the next block

                        Hi, in this case, the ((UINT)-3) will be converted to 3, advansing the position in the file instead of going back, the cast should be in the sizeof : file->Seek (-3 * (long)sizeof(BYTE), CFile::current);

                        N Offline
                        N Offline
                        Nelek
                        wrote on last edited by
                        #17

                        :doh::doh: you are totally right. Thanks for avoiding me an assertion ;) EDIT: I executed the program with my first option and worked ok, but i have anyways changed it

                        Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups