|
|
View previous topic :: View next topic |
Author |
Message |
JGoodman
Joined: 25 Aug 2005 Posts: 8
|
Whats wrong with this program? |
Posted: Thu Aug 25, 2005 10:42 am |
|
|
Hello,
My compiler is giving me errors and and can't seem to figure out whats bothering it.
Here is the error report:
Code: |
*** Error 28 "E:\picprojects\pic c\menu_data.c" Line 20(14,18): Expecting an identifier
*** Error 53 "E:\picprojects\pic c\menu_data.c" Line 70(3,9): Expecting function name
*** Error 66 "E:\picprojects\pic c\menu_control.c" Line 87(29,33): Previous identifier must be a pointer
*** Error 66 "E:\picprojects\pic c\menu_control.c" Line 90(29,33): Previous identifier must be a pointer
4 Errors, 0 Warnings.
|
The first error refers to the following code:
Code: |
typedef struct menu_choices
{
char name[12];
}mchoice;
mchoice *menuPtr; // create a global structure pointer called
// 'menuPtr'
void menu_0(void)
{
mchoice menu[5]; //Create array of structures of type
// 'mchoice
strcpy(menu[0].name," ");
strcpy(menu[1].name,"1) Fire");
strcpy(menu[2].name,"2) Setup");
strcpy(menu[3].name,"3) Doodle");
strcpy(menu[4].name,"4) Noodle");
menuPtr = &menu; // Set the global pointer to the local structure
// 'menu' (this is line 20)
}
|
I don't understand why the compiler is "expecting an identifier," I thought I made a global declaration!
As for the second error, I really have no clue what the problem is. Here's the code it refers to:
Code: |
void menu_director(int menu_map[])
{
// These arrays are each of the menu's "menu-map" codes
int menu_0[1] = {0};
int menu_01[2]= {0,1};
//Take current menu-map code, compare with one of the codes
//and return the correct menu data
if(compare_array(1,menu_map,menu_0))
menu_0(); //This is line 70
if(compare_array(2,menu_map,menu_01))
menu_01;
}
|
The last two errors seem to be one issue. I am guessing it has something to do with my global pointer declaration.
Heres the code:
Code: |
void display_choices(int upper,int lower) // If nothing to display
// put a 0 in upper or lower
{
lcd_gotoxy(2,1);
lcd_putc(*menuPtr[upper]->name); // This is line 87
lcd_gotoxy(2,2);
lcd_putc(*menuPtr[lower]->name); // This is line 90
}
|
If anyone could help me out, I would much appreciate it!
-Thanks
J Goodman |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 25, 2005 10:53 am |
|
|
You have got a function and an array with the same name: menu_0
Quote: | void menu_director(int menu_map[])
{
// These arrays are each of the menu's "menu-map" codes
int menu_0[1] = {0};
int menu_01[2]= {0,1};
//Take current menu-map code, compare with one of the codes
//and return the correct menu data
if(compare_array(1,menu_map,menu_0))
menu_0(); //This is line 70
if(compare_array(2,menu_map,menu_01))
menu_01;
} |
|
|
|
JGoodman
Joined: 25 Aug 2005 Posts: 8
|
|
Posted: Thu Aug 25, 2005 10:55 am |
|
|
Hello again,
Ok I only have one error now.
For the error on the menu_0() function, I renamed it to something slightly different, and that made the compiler happy.
Regarding the error on I changed it to and that fixed it
The only error that is left is the one on the the global pointer definition.
If anyone knows what I'm doing wrong, I'd be quite greatful for help!
-Thanks PCM Programmer for your continuing assistance
-J Goodman |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Aug 25, 2005 11:05 am |
|
|
should be
Code: |
menuPtr = &menu[0]; // Set the global pointer to the local structure
|
or
Code: |
menuPtr = menu; // Set the global pointer to the local structure
|
also "->" is pointer notation. You should have done this
|
|
|
JGoodman
Joined: 25 Aug 2005 Posts: 8
|
|
Posted: Thu Aug 25, 2005 11:57 am |
|
|
Thank you for your help. That fixed the error
In regard to the " -> " notation, thats what I originally wrote. But the compiler gave me the following error:
Code: |
*** Error 66 "E:\picprojects\pic c\menu_control.c" Line 87(28,32): Previous identifier must be a pointer
*** Error 66 "E:\picprojects\pic c\menu_control.c" Line 90(28,32): Previous identifier must be a pointer
|
Here is my code:
Code: |
void display_choices(int upper,int lower) // If nothing to display
// put a 0 in upper or lower
{
lcd_gotoxy(2,1);
lcd_putc(menuPtr[upper]->name); //This is line 87
lcd_gotoxy(2,2);
lcd_putc(menuPtr[lower]->name); //This is line 90
}
|
Please tell me what I am doing wrong.
-Thanks
J Goodman |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Aug 25, 2005 12:56 pm |
|
|
This is wrong
Code: |
menuPtr[upper]->name
|
This is right
menuPtr is not an array of pointers, hince menuPtr[#] would be wrong.
Is it clear now? |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
How did you manage to configure CCS compiler? |
Posted: Thu Aug 25, 2005 1:11 pm |
|
|
JGoodman wrote: | Code: |
*** Error 28 "E:\picprojects\pic c\menu_data.c" Line 20(14,18): Expecting an identifier
*** Error 53 "E:\picprojects\pic c\menu_data.c" Line 70(3,9): Expecting function name
*** Error 66 "E:\picprojects\pic c\menu_control.c" Line 87(29,33): Previous identifier must be a pointer
*** Error 66 "E:\picprojects\pic c\menu_control.c" Line 90(29,33): Previous identifier must be a pointer
4 Errors, 0 Warnings.
|
|
How did you configure the CCS compiler IDE to give a list of compile-time errors? My IDE (PCWH, v3.209, I have to use this version) gives compile-time errors in message boxes. Is the error list a new feature? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Aug 25, 2005 1:12 pm |
|
|
This is probably from the output window of the MPLAB IDE. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|