Jump to content
Sign in to follow this  
Jacob Christ

Sizeof One-off Error...

Recommended Posts

I'm using 6.89 and compiling a program that has a global variable defined something like this:

 

char foo[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
		   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
		   0x20, 0x21 };
function() {
  unsigned int size;
  size = sizeof(foo); // returns 0x21, expect 0x22
}

If I declare the foo as such:

char foo[0x22] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
			   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
			   0x20, 0x21 };
function() {
  unsigned int size;
  size = sizeof(foo); // returns 0x22 
}

If I declare the foo as such:

char foo[0x21] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
			   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
			   0x20, 0x21 };

 

The compiler complains:

 

code.h(229:4): error: too many initializers

 

Looking at the casm file, all the values get initialized and if I hard code 0x22 instead of using sizeof my program works as expected and the foo[21]st element is read properly.

 

Jacob Christ

Share this post


Link to post
Share on other sites

Thanks for reporting. This error was introduced in 6.89 and is already fixed in our development compiler copy. The fix will be available in the coming release 6.90.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Wow. I just noticed the revision number is 6.89. Does this mean we only get 10 more updates before a major revision that requires an upgrade fee? I'm not complaining. Your products are worth more than you charge. I'm just curious.

Share this post


Link to post
Share on other sites
Wow. I just noticed the revision number is 6.89. Does this mean we only get 10 more updates before a major revision that requires an upgrade fee? I'm not complaining. Your products are worth more than you charge. I'm just curious.

 

We don't have any firm dates for 7.00 release. It will happen but we have not planned yet when. We have a number of major new fetures we want to add there and we guess that whenever we are done with them or are close than it'll be time for 7.00 release.

 

Regards,

Pavel

 

BTW 6.90 release candidate is available to download from SourceBoost web site.

Share this post


Link to post
Share on other sites
Wow. I just noticed the revision number is 6.89. Does this mean we only get 10 more updates before a major revision that requires an upgrade fee? I'm not complaining. Your products are worth more than you charge. I'm just curious.

 

We don't have any firm dates for 7.00 release. It will happen but we have not planned yet when. We have a number of major new fetures we want to add there and we guess that whenever we are done with them or are close than it'll be time for 7.00 release.

 

Regards,

Pavel

 

BTW 6.90 release candidate is available to download from SourceBoost web site.

 

I vote for bit fields in structures... This will make it easier to use Microchip example code in BoostC

 

Jacob

Share this post


Link to post
Share on other sites
...I vote for bit fields in structures... This will make it easier to use Microchip example code in BoostC...

 

We have not looked at bit fields yet :) The reason (maybe not a good one) is that I personally never used or had a need in bit fields and because I'm responsible for a big part in the BoostC I am just not sure how big is the demand in this feature. That's not all. Once we get convinced that BooctC needs bit fields we'll need to come up with a model how bit fields work (as an example can a field be used as an operand in an expression how to do this efficiently in PIC assembly). Once we get past this bit we'll have good understanding how much changes the compiler requires to support this new feature and will be able to come up with development time line.

 

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...