type qualifier mismatch in assignment

Discussion in 'Programmer's Corner' started by Nanyang, Mar 7, 2012.

  1. Nanyang

    Thread Starter New Member

    Mar 7, 2012
    Hi all,

    I would like to ask for some feedback as to why my programming is having this comment when I build using MPLAB. ("Warning [2066] type qualifier mismatch in assignment"). I can build it successfully but i would just like to know how to get rid of this comment.

    I am using PIC18f46k22 to interface between garmin gps and my computer for my project.

    This is part of my code.

    while(PIR1bits.TXIF ==0);
    while(PIR1bits.TXIF ==0);
    while(PIR1bits.TXIF ==0);
    while(PIR1bits.TXIF ==0);
    while(PIR1bits.TXIF ==0);
    while(PIR1bits.TXIF ==0);
    while(PIR1bits.TXIF ==0);

  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    Short answer:
    Don't "get rid of this comment."
    Do "fix the mismatch"

    A "type qualifier" means you are trying to count apples as oranges. Now in certain situations it is acceptable to cast an apple as a fruit. Other situations this should not be done.

    By issuing just a warning the compiler is saying "I can guess here, but you should check my guess."

    Now for someone to help you check the type mismatch you need to supply the line where the error occurs, and the definition of all symbols (variables and such) used on that line.

    As C errors tend to cascade make the attempt to fix the first error first in the compile output.
  3. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    And it would help if you mentioned the compiler. Assuming this is C18 and this is the Microchip uart library, the library is compiled for the large code model. Change your compiler settings accordingly and it should solve the problem.

    I am not sure if there is a uart library compiled for the small model or not.
  4. MrChips


    Oct 2, 2009
    Sometimes compilers have a hard time pinpointing the exact source of the error.
    It is best to show all the code unless it is too long to post and you can narrow it down to a specific section of the code.

    You also have to show how the variables are declared in a case like this since the error is a type mismatch.