CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC18F252, CCS-IDE 3.249, predefined global variable i

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ulg



Joined: 09 May 2019
Posts: 24

View user's profile Send private message

PIC18F252, CCS-IDE 3.249, predefined global variable i
PostPosted: Tue Jul 09, 2019 1:03 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 09, 2019 1:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jul 09, 2019 2:24 am     Reply with quote

OK - I found them with "gerp j *.c": Evil or Very Mad

Code:

standard_lbr.c:  byte    i,j,k;
standard_lbr.c:  integer ii,jj,kk;
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 09, 2019 2:59 am     Reply with quote

Those must be your own files, because a web search with Google doesn't
find them.
ulg



Joined: 09 May 2019
Posts: 24

View user's profile Send private message

PostPosted: Tue Jul 09, 2019 9:55 am     Reply with quote

Yep - not my file, but a file created by one of my predecessors!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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