|
|
View previous topic :: View next topic |
Author |
Message |
Diogo Melo
Joined: 04 Aug 2008 Posts: 4 Location: ISEL,Lisbon, Portugal
|
constant arrays of strings |
Posted: Mon Aug 04, 2008 11:03 pm |
|
|
hi, i'm trying to get this to work in v4.057:
Code: | const char source[4][25]= {"Note "
,"Velocity "
,"Aftertouch "
,"Control Change "
};
char bufferStr2[25];
pnt=source[currentPos]; //currentPos is a char type variable
memmove(bufferStr2,pnt,25);
|
and all i get in bufferStr2 is nothing good: just random "trash" from the PICs memory banks.
This actually works if i remove the const from the array.
i've also tried to follow the second example from this page but i get the same errors :http://www.ccsinfo.com/content.php?page=flexconst. and i also tried every hint i could find in this forum.
Could anyone give me a hand.
Thanks
Diogo |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 05, 2008 12:57 am |
|
|
The program shown below has the following output:
Quote: |
Note
Velocity
Aftertouch
Control Change
|
Code: | #include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
const char source[4][25]= {
"Note ",
"Velocity ",
"Aftertouch ",
"Control Change "
};
//=========================
void main()
{
char *ptr;
char bufferStr2[25];
int8 i;
for(i = 0; i < 4; i++)
{
strcpy(bufferStr2, source[i]);
printf("%s \n\r", bufferStr2);
}
while (1);
} |
|
|
|
Diogo Melo
Joined: 04 Aug 2008 Posts: 4 Location: ISEL,Lisbon, Portugal
|
|
Posted: Tue Aug 05, 2008 2:19 pm |
|
|
PCM programmer wrote: | The program shown below has the following output:
Quote: |
Note
Velocity
Aftertouch
Control Change
|
Code: | #include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
const char source[4][25]= {
"Note ",
"Velocity ",
"Aftertouch ",
"Control Change "
};
//=========================
void main()
{
char *ptr;
char bufferStr2[25];
int8 i;
for(i = 0; i < 4; i++)
{
strcpy(bufferStr2, source[i]);
printf("%s \n\r", bufferStr2);
}
while (1);
} |
|
thanks! apparently i shouldn't have been using the memmove() function. I started using it when i had some troubles with strcpy() when i was using an older version of the compiler.
an unrelated thing: do you know if the compiler has somekind of problem with an array of structures? i keep getting an error in the mplab watch window: Unsupported Struct. do you know anything about it?
thanks again.
diogo |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Aug 05, 2008 5:35 pm |
|
|
The release note for 4.076 says: Quote: | 4.076 The COFF file format has been modified to allow MPLAB to read complex structures | This indicates the object file in earlier versions had some limitations... |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|