[LCP] Struggling with Pointers

Christopher Howard choward at indicium.us
Sat Jan 16 08:03:04 EST 2010


Paul Otheim wrote:

> 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
>  
>  ......
> }
> 

No, the prototype for your function doesn't go inside another function.
(Main is a function.)

If you have declared insertEntry() in the same file, previous to the
place where you intend to use it, you don't actually need a function
prototype. Function prototypes are for if you want to use a function
before you have actually defined what it does internally. Function
prototypes usually go in header files.

It also appears that you have not coded a definition for "struct entry"
before line 8, which is confusing the compiler. See any tutorial on C
structs.

-- 
Christopher Howard
http://indicium.us
http://theologia.indicium.us
http://robots.arsc.edu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 261 bytes
Desc: OpenPGP digital signature
Url : http://lists.linux.org.au/pipermail/linuxcprogramming/attachments/20100115/ebd5eeb8/attachment.pgp 


More information about the linuxCprogramming mailing list