View previous topic :: View next topic |
Author |
Message |
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
Attempt to create a pointer to a constant... |
Posted: Mon Jun 25, 2012 1:15 pm |
|
|
Confused about this, cant get it running.
All time: Code: | Attempt to create a pointer to a constant |
Compiler: 4132,4133,4134 same result.
Have tried a lot now, any help on this?
All is working nice in "CodeBlocks"
**Only testing code**
Code: | #include "18F25K22.h"
const char St1[][3]={ "T1", "T2", "T3" };
void T1(){
char TBuff[10];
int8 i=1;
sprintf(TBuff,St1[i]); //->error came here!
}
void main(){
T1();
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Jun 25, 2012 2:35 pm |
|
|
1) Read the manual - search for this error.
2) Unfortunately, some of the 'fixes' for this, seem not at present to be working. Look at this thread (only a few days ago).
<http://www.ccsinfo.com/forum/viewtopic.php?t=48456>
Best Wishes |
|
|
balmer
Joined: 31 May 2010 Posts: 6
|
|
Posted: Mon Jun 25, 2012 5:28 pm |
|
|
You may try with strcpy( ) isof sprintf(), as for this function source of data may be either a pointer to a RAM array of characters or it may be a constant string.
Code: |
const char St1[][3]={ "T1", "T2", "T3" };
void T1(){
char TBuff[10];
int8 i=1;
strcpy(TBuff,St1[i]);
}
void main(){
T1();
}
|
|
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Tue Jun 26, 2012 5:41 am |
|
|
Hi
Thanks for your reply and link on this @Ttelmah.
I have exact the same problem, 4129 is running well but after that version the problem start.
I have reported to CCS for month ago on 4131 but no reply, some days ago I reported the same in 4133 but no reply at all??
Can see @PCM programmer have reported it too but no reply.
Hmmm hope CCS will fix what the was running in the past. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Tue Jun 26, 2012 7:27 am |
|
|
Realistically this goes back to the (sad but true) mantra, that 'new versions from CCS, are beta at best'.
Unless you need a feature offered by a new version, it is much safer to stick with the known. 'Routine upgrading' with CCS is something that should not be done. When you start a project, keep the compiler you use with it, and if you install a new version, keep the old as well.
In the front of all my projects, you will find a list of the project version numbers, what I've changed/fixed, but also what compiler was used with the code, and when the code is archived, the compiler goes with it.....
They for a little while seemed to have slightly improved, with several versions in the low four dot one hundred's appearing without introducing new problems, but unfortunately seem to have gone 'back' to their old habit again now. :(
I wonder what happens if you take the new .dat file from (say) 4.133, and try it with something like 4.128?. Might give the new chips (of which there are quite a lot recently), without the problems
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jun 26, 2012 9:42 am |
|
|
Ttlemahs advice is excellent on this matter.
i suggest using a new compiler version under 3 well defined conditions:
1- to gain support for a NEW PIC part
2- for a useful new addition to the intrinsics that a new version offers
3- to fix a bug
"because i can" is not a reason to switch |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Thu Jun 28, 2012 5:29 am |
|
|
**The problem is confirmed by CCS will be fixed in next release:-)** |
|
|
|