RE: realloc and Segmentation Fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Shan wrote:

> But the compiler still complains of conflicting types.
:
> void func1(struct bucket *(*pvalid))
> {
>     /*this code causes errors*/
>     *pvalid = insert_to_bucket(*pvalid);
> }

If you mean that line causes a conflicting type error on the
insert_to_bucket definition -

The problem is now that you're trying to call insert_to_bucket before you've
declared it: at this point the compiler doesn't know what insert_to_bucket
is so it guesses a function signature for it and then finds out later that
it was wrong. Either declare insert_to_bucket first, i.e. add this line

    struct bucket *insert_to_bucket(struct bucket *valid);

before func1, or move func1 down to after insert_to_bucket in the code.

Other than that your code should compile fine, assuming you're #including
stdio.h and stdlib.h.

Rup.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux