Jump to content

Array Of Pointers Doesn't Seem To Work?


Recommended Posts

Hi

 

I'm using

 

Executing: "C:\Program Files\SourceBoost\boostc.pic18.exe" flash.c -O1 -W2 -v -t 18F4523 -I boostc_libs_r1_3\libs

BoostC Optimizing C Compiler Version 6.87 (for PIC18 architecture)

http://www.sourceboost.com

Copyright© 2004-2008 Pavel Baranov

Copyright© 2004-2008 David Hobday

 

Licensed to Mark Murray under Single user Full License for 1 node(s)

Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only

 

With the following data structure (generated using a script)

 

static unsigned char *eepromlist[] = {

digit_18x24_0,

digit_18x24_1,

digit_18x24_2,

digit_18x24_3,

eeprom_gap_0,

digit_18x24_4,

digit_18x24_5,

digit_18x24_6,

digit_18x24_7,

eeprom_gap_1,

digit_18x24_8,

digit_18x24_9,

NULL

};

 

 

The following loop does not terminate at the NULL:

 

for (i = 0; eepromlist != NULL; i++) {

 

// do stuff with eepromlist[]

 

}

 

instead, it runs off into an infinite(?) loop.

 

Any ideas?

 

M

Link to post
Share on other sites

Can't reproduce the problem. Below is the code I tried and it works just fine:

 

#include <system.h>

char *digit_18x24_0 = 1, *digit_18x24_1 = 2, *eeprom_gap_0 = 3;
static unsigned char *eepromlist[] = {
digit_18x24_0,
digit_18x24_1,
eeprom_gap_0,
NULL
};


void main()
{
char i, s = 0;

for (i = 0; eepromlist[i] != NULL; i++)
{

	s++;

}

while( 1 );
}

 

Regards,

Pavel

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...