LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-09-2009, 09:10 AM   #1
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 158

Rep: Reputation: 30
unable to resolve compilation error;./List.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’


i have written a code it has a list.h and list .c files ..h has function prototypes and data structures ,type def etc.while .c file has function implementation
list.h
Code:
#ifndef _List_
#define _List_





struct _ListElement{
  void*data;
  struct _ListElement *next,*previous;
};
typedef struct _ListElement ListElement;


typedef struct{
  int listlength;
  ListElement *head,*tail;

}List;

ListElement* newListElement(void*data,ListElement* next,ListElement* previous);
List* newList();
void insertElementToList(List* l, void* data,int n/*after n links*/);
void prependToList(void *data,List*l);
void appendToList(List* l, void*data);
void** listToSortedArray(List*l,pt2CompareFunction comp,int flag)
void** listToArray(List*l);
void removeElementFromList(List *l, int n);
void freeList(List *l);

#endif
and List.c
Code:
#include <stdlib.h>
#include "PQueue.h"
#include "List.h"

ListElement* newListElement(void *data,ListElement *previous,ListElement *next){
  ListElement*e;
  e=(ListElement*)malloc(sizeof(ListElement));
  e->data=data;
  e->next=next;
  e->previous=previous;
  return  e;
}

List* newList(){
  List* l;
  l=(List*)malloc(sizeof(List));
  l->listlength;
  l->head=newListElement(NULL,NULL,NULL);
  l->tail=newListElement(NULL,NULL,NULL);
  l->head->next=l->tail;
  l->tail->previous=l->head;
  return l;
}

void insertElementToList(List* l, void* data,int n/*after n links*/){
  ListElement* Iter,*e;
  int i=0;
  Iter=l->head;
  for (i=0;i<n;i++)
    Iter=Iter->next;
  e=newListElement(data,Iter,Iter->next );
  Iter->next->previous=e;
  Iter->next=e;
   (l->listlength)++;
}

void prependToList(void *data,List*l){
  ListElement *e;
  e=newListElement(data,l->head,l->head->next);
  l->head->next->previous=l->head->next;
  l->head->next=l->head->next;
  l->listlength++;
}


void appendToList(List* l, void*data){
  ListElement *e;
  e=newListElement(data,l->head,l->head->next);
  l->tail->previous->next=e;
  l->tail->previous=e;
  l->listlength++;
}

void** listToSortedArray(List*l,pt2CompareFunction comp,int flag){
  int i;
  ListElement *iter;
  iter=l->head;
  PQueue *q= new_PQueue(l->listlength,flag,comp);
  for(i=0;i<l->listlength;i++){
    iter=iter->next;
    PQinsert_2(iter->data,iter->data,q);
  }
  void** arr=malloc(sizeof(void**)*l->listlength);
  for(i=0;i<l->listlength;i++){
    arr[i]=PQremoveRoot(q);
  }
  return arr;
}

void** listToArray(List*l)
{
  void **arr= malloc(sizeof(void**));
  int i;
  ListElement *iter;
  iter=l->head;
  for(i=0;i<l->listlength;i++){
    iter=iter->next;
    arr=iter->data;
  }
  return arr;
}

 

void removeElementFromList(List *l, int n){
 int i;
  ListElement *iter;
  iter=l->tail;
  for(i=0;i<n;i++){
    iter=iter->previous;
  }
  iter->next->previous=iter->previous;
  iter->previous->next=iter->next;
  free(iter);

 }

void freeList(List*l){
 int i;
  ListElement *iter;
  iter=l->tail;
  for(i=0;i<l->listlength;i++){
    iter=iter->previous;
    free(iter->next);
  }
  free(l->head);
  free(l->tail);
}

the error message looks like

Code:
 gcc -c ./List.c 
./List.c: In function ‘listToSortedArray’:
./List.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:37: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:46: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:54: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:71: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:85: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:98: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
./List.c:108: error: old-style parameter declarations in prototyped function definition
./List.c:108: error: expected ‘{’ at end of input
though the code is long but i am asking for a specific error


expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token



i don't even understand what this error means.

please help me out
thanks
Amol

Last edited by amolgupta; 01-09-2009 at 09:12 AM.
 
Old 01-09-2009, 09:14 AM   #2
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 158

Original Poster
Rep: Reputation: 30
sorry i had made a mistake in copying the code i have just corrected it
just in case if some one might have checked the older post
 
Old 01-09-2009, 09:28 AM   #3
ErV
Senior Member
 
Registered: Mar 2007
Location: Russia
Distribution: Slackware 12.2
Posts: 1,202
Blog Entries: 3

Rep: Reputation: 62
I think problem is here (list.h):
Code:
void** listToSortedArray(List*l,pt2CompareFunction comp,int flag)
void** listToArray(List*l);
";" is missing at the end of line with "listToSortedArray(...)".
 
Old 01-09-2009, 10:09 AM   #4
amolgupta
Member
 
Registered: Feb 2005
Location: agra,india
Distribution: FC2
Posts: 158

Original Poster
Rep: Reputation: 30
thanks
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Removed HD resulted in "Unable to resolve LABEL " error during boot nooto Linux - Hardware 2 12-26-2008 08:58 AM
error: expected specifier-qualifier-list before ‘t_scalar_t’ sunilvadranapu SUSE / openSUSE 1 09-04-2008 01:30 PM
"expected specifier-qualifier-list" ERROR while adding a new system call ahm_irf Linux - Kernel 0 04-29-2007 10:52 PM
Error: Unable to resolve GL/GLX symbols - please check your GL library installation. Dquest Linux - General 8 11-02-2005 05:31 AM
mixxx under suse 9.1 fatal error Unable to resolve GL/GLX symbols ranjo Linux - Software 3 06-20-2004 03:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration