[LCP] Struggling with Pointers

Paul Otheim coriolis220 at gmail.com
Sat Jan 16 07:18:56 EST 2010


If there is a better place for such a basic question I would appreciate a
pointer to said place, otherwise...

I am trying to insert a new entry into a linked list. I cannot however seem
to even get the function declaration right. I keep getting errors like this
from gcc.

gcc -o insert insertEntry.c
insertEntry.c:8: warning: ‘struct entry’ declared inside parameter list
insertEntry.c:8: warning: its scope is only this definition or declaration,
which is probably not what you want
insertEntry.c: In function ‘main’:
insertEntry.c:20: error: conflicting types for ‘insertEntry’
insertEntry.c:8: note: previous definition of ‘insertEntry’ was here


void insertEntry (struct entry *new, struct entry *here) //this is line 8
{
 .....
}

int main (void)
{
  void insertEntry (struct entry *new, struct entry *here);  // this is line
20

 ......
}

I have tried many variations on it but I don't seem to be able to get it
right. Should I not declare insertEntry() in main?
I was under the impression that you should always put a prototype
declaration in main.
According to the book I am reading you have to declare the pointer to be of
the appropriate type in the function declaration.
So I don't understand  the warning, which I might ignore, though I'd rather
not but then I get the conflicting types error and the
party stops there.


gcc --version
gcc (GCC) 4.4.2 20091222 (Red Hat 4.4.2-20)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/linuxcprogramming/attachments/20100115/03ec3657/attachment.htm 


More information about the linuxCprogramming mailing list