8051 >> HI-TECH C PRO for the Silicon Labs 8051 MCU Family

Pages: 1
bstjacques
Tester


Reged: Jul 09 2007
Posts: 2
Array/Pointer Warning
      #59972 - Fri Jun 06 2008 02:59 PM

Hi there,

I am recompiling a known Keil project with the latest Hi Tech compiler. This is a USB application using some reference code from SiLabs application notes. There are 3 string constants in code memory for the USB descriptors and an array that is supposed to point to each of the 3 strings.

The strings are declared like this:

const unsigned char String2Desc[STR2LEN] = ...

And the array of pointers to the strings is declared like this:

unsigned char* const StringDescTable[] =
{
String0Desc,
String1Desc,
String2Desc
};

I am getting warning "(359) illegal conversion between pointer types", but the code is still compiling. I would like get rid of the warning and be sure that everything is going to work correctly - any suggestions?

Aside from that, the program space with the Hi Tech compiler is 92% of what Keil is generating and the data space is coming in at 119%.

Thanks.

--------------------
Brian St Jacques


Post Extras: Print Post   Remind Me!   Notify Moderator  
bstjacques
Tester


Reged: Jul 09 2007
Posts: 2
Re: Array/Pointer Warning [Re: bstjacques]
      #59982 - Fri Jun 06 2008 05:11 PM

So, I got rid of that warning by changing the declarations to:

code const unsigned char String2Desc[STR2LEN] =...

code const unsigned char* StringDescTable[] =
{
String0Desc,
String1Desc,
String2Desc
};

I still have a warning about the illegal conversion between pointer types, but it is because I am assigning one of the elements of StringDescTable to a generic unsigned char pointer variable that is not declared as "code const". Strange to me that it is described as "illegal" but only throws a warning?

My USB device is not enumerating correctly under the HT build, so I think I have it down to either this being the problem, or there is an initialization source file that Keil provides to be built in to your projects. I omitted this thinking that HiTech would generate their own initialization code, but maybe there is something needed in there?

--------------------
Brian St Jacques


Post Extras: Print Post   Remind Me!   Notify Moderator  
clydeAdministrator
HI-TECH team member
*****

Reged: Oct 16 2003
Posts: 622
Re: Array/Pointer Warning [Re: bstjacques]
      #60022 - Sat Jun 07 2008 01:14 AM

It should be:
Code:

const unsigned char * const StringDescTable[] =
{
String0Desc,
String1Desc,
String2Desc
};


IOW this is a const array of pointers to const unsigned char.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:  Andrew L, clyde, Brent W, jeff, dave g, meisty, josh stevo 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 719

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5