|
|
View previous topic :: View next topic |
Author |
Message |
ulg
Joined: 09 May 2019 Posts: 24
|
PIC18F252, CCS-IDE 3.249, predefined global variable i |
Posted: Tue Jul 09, 2019 1:03 am |
|
|
I have two days of troubleshooting behind me, because the compiler
has compiled this flawed source code without a trace!
Code: |
char colDataMMI(tStoreRecall job, char* pChr) { //[
//[ brief ///
// Setter and Getter for MMI data.
// When passing job == SAVE, characters located at pChr will be stored,
// when passing job == GETi (GET0..GET9), character with index i will
// be recalled and returned.
//] brief ///
static char dataMMI[10] = {0};
char chr = 0;
if ((job == SAVE) && pChr) {
int8_t cnt;
for (cnt = 0; cnt < 10; cnt++) {
dataMMI[i] = pChr[i];
}
} else if ((job >= GET0) && (job <= GET9)) {
chr = dataMMI[job];
}
return chr;
} //]
|
First I thought, one of my predecessors has defined a global variable i,
but grepping for "i;", "i=" and "i =" hasn't provided any such declaration -
it seems, the compiler provides a predefined global variable i? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 09, 2019 1:20 am |
|
|
CCS vs. 3.249 is from 2006. We are now at vs. 5.085 in 2019.
Compiling the test program shown below with vs. 5.085 gives an error
for the undeclared 'i' variable.
Quote: |
Compiling C:\Program Files\PICC\Projects\PCH_Test\PCH_Test on 09-Jul-19 at 00:16
*** Error 12 "C:\Program Files\PICC\Projects\PCH_Test\PCH_Test.c" Line 25(18,19): Undefined identifier i
1 Errors, 0 Warnings.
Build Failed.
Halting build on first failure as requested.
BUILD FAILED: Tue Jul 09 00:16:22 2019
|
Test program:
Code: | #include <18F46K22.h>
#fuses NOWDT,PUT,BROWNOUT
#use delay(internal=4M)
#use rs232(baud=9600, UART1, ERRORS)
#include <stdint.h>
typedef int8 tStoreRecall;
#define SAVE 0
#define GET0 0
#define GET9 9
char colDataMMI(tStoreRecall job, char* pChr)
{
static char dataMMI[10] = {0};
char chr = 0;
if((job == SAVE) && pChr)
{
int8_t cnt;
for(cnt = 0; cnt < 10; cnt++)
{
dataMMI[i] = pChr[i];
}
}
else if ((job >= GET0) && (job <= GET9))
{
chr = dataMMI[job];
}
return chr;
}
//=================================
void main()
{
int8 retval;
int8 temp[10];
retval = colDataMMI(5, temp);
while(TRUE);
} |
|
|
|
ulg
Joined: 09 May 2019 Posts: 24
|
|
Posted: Tue Jul 09, 2019 2:24 am |
|
|
OK - I found them with "gerp j *.c":
Code: |
standard_lbr.c: byte i,j,k;
standard_lbr.c: integer ii,jj,kk;
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 09, 2019 2:59 am |
|
|
Those must be your own files, because a web search with Google doesn't
find them. |
|
|
ulg
Joined: 09 May 2019 Posts: 24
|
|
Posted: Tue Jul 09, 2019 9:55 am |
|
|
Yep - not my file, but a file created by one of my predecessors! |
|
|
|
|
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
|