Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C18 Warning [2066] type qualifier mismatch in assignment

Status
Not open for further replies.

Rikr09

Member level 3
Member level 3
Joined
Feb 14, 2013
Messages
59
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,745
Hello Edaboard Friends,

Im trying to use the STRCOPY method to send many Message throw the UART of the microcontroller, but im getting the Warning message "Warning [2066] type qualifier mismatch in assignment" on MPLAB and the "Haaaaa" message is not load on mi_ficha.Nombre Buffer ... The warning is because of: strcpy(mi_ficha.Nombre,"Haaaaaa");

Code:
struct ficha{
    char Nombre[20];
};
struct ficha mi_ficha;

strcpy(mi_ficha.Nombre,"Haaaaaa");

      for(i=0; i<=strlen(mi_ficha.Nombre); i++){
          imprimirCaracterU1(mi_ficha.Nombre[i]);
      }

Thanksss for your help!
 

The type mismatch is because the function strcpy expects both arguments in ram, but "Haaaaaa" is stored in program space. You need to use the function strcpypgm2ram
It is one of the big pains about the pic 8bit processors that all constants are stored in flash and need different routines to access.

There is a complete collection of routines corresponding to the standard string routines to access constant memory

mike
 

The type mismatch is because the function strcpy expects both arguments in ram, but "Haaaaaa" is stored in program space. You need to use the function strcpypgm2ram
It is one of the big pains about the pic 8bit processors that all constants are stored in flash and need different routines to access.

There is a complete collection of routines corresponding to the standard string routines to access constant memory

mike


Thanks for your reply Mike, i did this:

Code:
strcpypgm(mi_ficha.Nombre,"Holaaa");

ant the Warning appears again.... :S
 

EDIT: reread my original post and see that I didn't mistype (so I was a little less wrong!)

Sorry about that.

First I mistyped and you need strcpypgm2ram();
Secondly I guess it's been a while since I did C18 compiles and even with the correct function you still get the error.
The reason is because of near/far pointers. Even on small PICS (<64K ROM) there is a problem because by default all of the libraries assume a far (24bit) pointer and the default for small PICs is a small memory model(16-bit) pointers.

In this case the code will compile AND execute properly, but still give you the warning.

to fix the warning the function call must be
strcpypgm2ram(mi_ficha.Nombre, (const far rom char *) "Haaaaaa");

explicitly converting the near pointer to a far pointer.

As this happens frequently I usually create a typedef
typedef const far rom char * roms;

and then preface constant strings with a cast to roms i.e. (roms)

mike
 
EDIT: reread my original post and see that I didn't mistype (so I was a little less wrong!)

Sorry about that.

First I mistyped and you need strcpypgm2ram();
Secondly I guess it's been a while since I did C18 compiles and even with the correct function you still get the error.
The reason is because of near/far pointers. Even on small PICS (<64K ROM) there is a problem because by default all of the libraries assume a far (24bit) pointer and the default for small PICs is a small memory model(16-bit) pointers.

In this case the code will compile AND execute properly, but still give you the warning.

to fix the warning the function call must be
strcpypgm2ram(mi_ficha.Nombre, (const far rom char *) "Haaaaaa");

explicitly converting the near pointer to a far pointer.

As this happens frequently I usually create a typedef
typedef const far rom char * roms;

and then preface constant strings with a cast to roms i.e. (roms)

mike


Thanks again Mike for your explanation, i Did what you tell me but ... again the same error :( ...

Code:
strcpypgm(mi_ficha.Nombre,(const far rom char *)"Holaaa");

Warning [2066] type qualifier mismatch in assignment
 

Rikr09,

I suggest you reread Mike's last reply, you are not calling the correct routine.

Try:

Code:
strcpypgm[COLOR="#FF0000"]2ram[/COLOR](mi_ficha.Nombre, (const far rom char *) "Haaaaaa");

Instead Of:

Code:
strcpypgm(mi_ficha.Nombre,(const far rom char *)"Holaaa");


Also please post your entire code, rather than the small snippet, just to make sure there isn't something else going on of which we are not aware.


BigDog
 

Rikr09,

I suggest you reread Mike's last reply, you are not using the correct routine.

Try:

Code:
strcpypgm[COLOR="#FF0000"]2ram[/COLOR](mi_ficha.Nombre, (const far rom char *) "Haaaaaa");

Instead Of:

Code:
strcpypgm(mi_ficha.Nombre,(const far rom char *)"Holaaa");


Also please post your entire code, rather than the small snippet, just to make sure there isn't something else going on of which we are not aware.


BigDog


Excellent !!! :) Im sorry, i had my mind almost to explote jeje ... i didnt read exactly what Mike wrote me... I did one test and everything going EXCELLENT!! THANKS FOR EVERYBODY!! :-D:-D:-D:-D:-D:-D:-D:-D

PD: and according your advice BigDog i will do it!! Thanks for that! ;)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top