Jump to content
Sign in to follow this  
Reynard

Bug:static Variables Not Initialized.

Recommended Posts

A static array only initializes (zeroes) the first 2 bytes of the array.

 

Put the array inside a structure though and all bytes are initializes.

 

static unsigned char myArray[4];

static struct {

unsigned char myArray[4];

} myStruct;

 

produces assemly instructions:

 

static unsigned char myArray[4];

0004 1283 BCF STATUS, RP0

0005 1303 BCF STATUS, RP1

0006 01A0 CLRF gbl_11_myArray

0007 01A1 CLRF gbl_11_myArray+D'1'

 

static struct {

unsigned char myArray[4];

} myStruct;

0008 01A4 CLRF gbl_11_myStruct

0009 01A5 CLRF gbl_11_myStruct+D'1'

000A 01A6 CLRF gbl_11_myStruct+D'2'

000B 01A7 CLRF gbl_11_myStruct+D'3'

 

An array of int's does the same (only 2 bytes zeroed).

 

Using IDE & BoostC 6.81, PIC16F873A, Windows XP Pro SP2.

 

Cheers

 

Reynard

Share this post


Link to post
Share on other sites

This was fixed a while ago and fix is available in current release. Thanks for reporting.

 

Regards,

Pavel

Share this post


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...
Sign in to follow this  

×
×
  • Create New...