• C

[Simple] C Program Errors

I am trying to compile my C program and one of my header files is giving me alot of problems. How can I fix all of these errors?

linkedlist.h:7: warning: useless storage class specifier in empty declaration
linkedlist.h:12: error: expected specifier-qualifier-list before âNODEâ
linkedlist.h:23: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before ânewentryâ
linkedlist.h:25: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âremoveentryâ


#ifndef __LINKEDLIST_H
#define __LINKEDLIST_H
 
#define MAX_NAME_LENGTH 25
#define PHONE_NUMBER_LENGTH 12
 
typedef struct NODE;
typedef struct {
        char firstName[MAX_NAME_LENGTH];
        char lastName[MAX_NAME_LENGTH];
        char phoneNumber[PHONE_NUMBER_LENGTH];
        NODE *previousNode;
        NODE *nextNode;
} NODE;
 
typedef struct {
        NODE *firstNode;
        NODE *lastNode;
        NODE *currentNode;
        int counter;
} LINKEDLIST;
 
bool newentry(LINKEDLIST *myLinkedList, char *firstName, char *lastName, char *phoneNumber);
void displayall(LINKEDLIST myLinkedList);
bool removeentry(LINKEDLIST *myLinkedList, char *phoneNumber);
 
#endif

Open in new window

LVL 1
bejhanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Infinity08Commented:
Use :

        typedef struct NODE {
                char firstName[MAX_NAME_LENGTH];
                char lastName[MAX_NAME_LENGTH];
                char phoneNumber[PHONE_NUMBER_LENGTH];
                struct NODE *previousNode;
                struct NODE *nextNode;
        } NODE;

instead of :

        typedef struct NODE;
        typedef struct {
                char firstName[MAX_NAME_LENGTH];
                char lastName[MAX_NAME_LENGTH];
                char phoneNumber[PHONE_NUMBER_LENGTH];
                NODE *previousNode;
                NODE *nextNode;
        } NODE;

Also, bool is not a valid type in C, so you'll have to either define it somewhere, or choose a different type.
0
Infinity08Commented:
For example :
#ifndef __LINKEDLIST_H
#define __LINKEDLIST_H
 
#define MAX_NAME_LENGTH 25
#define PHONE_NUMBER_LENGTH 12
 
 
/*typedef struct NODE;*/                          /* <--- this line is removed !! */
typedef struct NODE {
        char firstName[MAX_NAME_LENGTH];
        char lastName[MAX_NAME_LENGTH];
        char phoneNumber[PHONE_NUMBER_LENGTH];
        struct NODE *previousNode;                /* <--- use struct NODE* here */
        struct NODE *nextNode;
} NODE;
 
typedef struct {
        NODE *firstNode;
        NODE *lastNode;
        NODE *currentNode;
        int counter;
} LINKEDLIST;
 
typedef int bool;                                 /* <--- add this */
 
bool newentry(LINKEDLIST *myLinkedList, char *firstName, char *lastName, char *phoneNumber);
void displayall(LINKEDLIST myLinkedList);
bool removeentry(LINKEDLIST *myLinkedList, char *phoneNumber);
 
#endif

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bejhanAuthor Commented:
I included stdbool.h to fix the bool error but still get

linkedlist.h:12: error: expected specifier-qualifier-list before âNODEâ

even with your change.
0
bejhanAuthor Commented:
Didn't see to add struct in front of the NODE elements. Works now.
0
Infinity08Commented:
>> Works now.

Great :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.