CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with pointers "Expecting a close paren "

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MMurray



Joined: 19 Feb 2011
Posts: 22

View user's profile Send private message

Problem with pointers "Expecting a close paren "
PostPosted: Sat Dec 10, 2011 10:53 am     Reply with quote

This code will not compile, I get the following error
*** Error 58 "Q Main.c" Line 101(13,14): Expecting a close paren
Line 101 is... addq(&front,&rear,1);

Does anyone have some insight to this issue?

Code:

#include <16F877A.h>

#Fuses hs NOWDT
#USE delay(crystal=20mhz)
#use rs232(baud=9600, xmit=PIN_C7, rcv=PIN_C6)

#include "pins.h"
#include "main.h"

//==========================================================
void addq(struct node **f,struct node **r,int item)
{
struct node *q;

q=malloc(sizeof(struct node));
q->data=item;
q->link=NULL;

if(*f==NULL)
*f=q;
else
(*r)->link=q;
*r=q;
}
//===========================================================
int count(struct node *q)
{
int c=0;

while(q!=NULL)
{
q=q->link;
c++;
}
return c;
}
//==========================================================

void main ()
{
initMain();
initHdwr();

int q_count=0;
struct node *front,*rear;
int item=0;

front=NULL;
rear=NULL;

addq(&front,&rear,1);

while (TRUE)
{
q_count=count(front);
printf(lcd_putc,"%d",q_count);
wait;
}
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19505

View user's profile Send private message

PostPosted: Sat Dec 10, 2011 11:26 am     Reply with quote

CCS, has a relatively poor syntax checker.
If you have an error in a line, it merrily plods on trying to interpret subsequent lines, until something completely impossible happens. When this happens, it is at this line that it flags the error.
Hence your error is almost certainly referring to something many lines earlier.
First thing to do, is go through each of the include files, and use the tool that finds the matching brackets, and verify that the numbers do balance in each file. Then do the same in the main.

Best Wishes
MMurray



Joined: 19 Feb 2011
Posts: 22

View user's profile Send private message

PostPosted: Sat Dec 10, 2011 12:02 pm     Reply with quote

Ran through that before posting, I just re-checked, I could not find any missing. Is there any thing else I should be looking for?
MMurray



Joined: 19 Feb 2011
Posts: 22

View user's profile Send private message

PostPosted: Sat Dec 10, 2011 12:07 pm     Reply with quote

Ha Ha!!!! I found it!!!

I broke the line

struct node *front,*rear;

into...

struct node *front;
struct node *rear;

Thanks
MMurray



Joined: 19 Feb 2011
Posts: 22

View user's profile Send private message

PostPosted: Sat Dec 10, 2011 12:11 pm     Reply with quote

No that did not help. I had commented out the offending line.

Help
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Dec 10, 2011 3:15 pm     Reply with quote

I could reproduce the error putting in this definition
Code:
struct node {
   int data;
   int *link;
};


Replacing it with my preferred typedef (saving keystrokes) and changing it's instances respectively made CCS C accept the code.
Code:
typedef struct {
   int data;
   int *link;
} NODE;

void addq(NODE **f,NODE **r,int item)

Apparently, CCS C gets confused with multiple struct keywords in the formal function parameter list.

I wonder however, if using dynamic memory with PIC16 is a good idea?
MMurray



Joined: 19 Feb 2011
Posts: 22

View user's profile Send private message

PostPosted: Sat Dec 10, 2011 4:41 pm     Reply with quote

Excellent! That has got it.
Thank you
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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