Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Array of pointer - needs help

Reply
Thread Tools

Array of pointer - needs help

 
 
vib
Guest
Posts: n/a
 
      10-07-2005
Hi there,

I am stuck with the following code. It is an array of pointers, in
ADS1.2 compiler I encounter the errors, but not on other compiler. Can
someone please shade some light, please! Frankly, I can't see anything
wrong with the code, but the compiler just refuse it as I wish.

Thanks in advance

vib

--------

unsigned int myvar1=1, myvar2=2;

const * unsigned int myArrayOfPtr[] = {
(* unsigned int)&myvar1,
(* unsigned int)&myvar2,
};

-------

Error : (Serious) C2322E: Expecting <declarator> or <type> but found
'unsigned'
lcd_drv.c line 92

Error : C2285E: expected ';' or ',' - inserted ';' before '{'
lcd_drv.c line 92

Error : (Serious) C2337E: Misplaced '{' at top level - ignoring block
lcd_drv.c line 92

Error : (Serious) C2291E: <expression> expected but found 'unsigned'
lcd_drv.c line 93

Error : (Serious) C2282E: expected ')' - inserted before 'unsigned'
lcd_drv.c line 93

Error : (Serious) C2284E: expected ';' after command - inserted
before 'unsigned'
lcd_drv.c line 93

Error : (Serious) C2304E: <command> expected but found 'unsigned'
lcd_drv.c line 93

Error : C2487E: declaration with no effect
lcd_drv.c line 95

C:\_ucos251_S5L8700x\BSP_S3C2400\src\lcd_drv.c: 0 warnings, 2 errors, 6
serious errors

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      10-07-2005
"vib" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi there,
>
> I am stuck with the following code. It is an array of pointers, in
> ADS1.2 compiler I encounter the errors, but not on other compiler. Can
> someone please shade some light, please! Frankly, I can't see anything
> wrong with the code, but the compiler just refuse it as I wish.
>
> Thanks in advance
>
> vib
>
> --------
>
> unsigned int myvar1=1, myvar2=2;
>
> const * unsigned int myArrayOfPtr[] = {
> (* unsigned int)&myvar1,
> (* unsigned int)&myvar2,
> };


const unsigned int *myArrayOfPtr[] =
{
&myvar1,
&myvar2
};

-Mike


 
Reply With Quote
 
 
 
 
vib
Guest
Posts: n/a
 
      10-07-2005

Mike Wahler wrote:
> const unsigned int *myArrayOfPtr[] =
> {
> &myvar1,
> &myvar2
> };
>
> -Mike


Haha! terrible mistake of mine.

Thanks Mike

 
Reply With Quote
 
Martin Ambuhl
Guest
Posts: n/a
 
      10-07-2005
vib wrote:
> Hi there,
>
> I am stuck with the following code. It is an array of pointers, in
> ADS1.2 compiler I encounter the errors, but not on other compiler.


Then your other compiler is broken. Your code is seriously wrong.

> Can
> someone please shade some light, please!


Your '*'s are all in the wrong places.

> unsigned int myvar1=1, myvar2=2;
>
> const * unsigned int myArrayOfPtr[] = {
> (* unsigned int)&myvar1,
> (* unsigned int)&myvar2,
> };


should be
const unsigned int *myArrayOfPtr[] = {
(unsigned int *)&myvar1,
(unsigned int *)&myvar2 /* losing the ',' also */
};

If you just *must* have those casts. But the presence of the casts
suggests that your code is misdesigned anyway. If myvar1 and and myvar2
are not unsigned ints, then you are probably asking for trouble later
on. If the are unsigned ints, then

const unsigned int *myArrayOfPtr[] = {&myvar1, &myvar2};
will do the job just fine.

And don't use tabs in usenet postings.
 
Reply With Quote
 
vib
Guest
Posts: n/a
 
      10-07-2005
Hi Martin,
Thanks for the advice.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer to an array vs pointer to pointer subramanian100in@yahoo.com, India C Programming 5 09-23-2011 10:28 AM
Cast a pointer to array to base class pointer to array Hansen C++ 3 04-24-2010 03:30 PM
Pointer to array of array of const pointer RSL C++ 14 02-19-2010 02:06 PM
Array of pointer and pointer of array erfan C Programming 6 01-28-2008 08:55 PM
Array of pointer Vs Pointer to Array sangeetha C Programming 9 10-09-2004 07:01 PM



Advertisments