Re: type mismatch

From: Artie Gold (artiegold_at_austin.rr.com)
Date: 02/28/04

  • Next message: spike: "Search a binary file for a string... again! (its to slow)"
    Date: Sat, 28 Feb 2004 14:20:42 -0600
    
    

    Frédéric Liné wrote:
    > I use gcc 3.2.2 and I got this warning :
    >
    > interface.c:501: warning: type mismatch with previous implicit declaration
    > interface.c:204: warning: previous implicit declaration of `parent'
    > interface.c:501: warning: `parent' was previously implicitly declared to return `int'
    >
    >
    > The line 204 is this one :
    >
    > p_parent = (GtkTreeIter *) parent();

    Some warnings are cryptic; this one, however, is not!

    Since there is no prototype for the function `parent()' in scope, the
    compiler assumes it returns `int' (and at some point, someone put in the
    ugly cast).

    When the compiler encountered the definition of `parent()' it went
    (colloquially): "Whoa! Since you hadn't told me different, I though it
    returned an `int'. Now you're telling me it returns a pointer to
    `GtkTreeInter'. I'd better issue a warning!"
    >
    >
    >
    >
    > And the definition of parent line 501 is as follows :
    >
    > GtkTreeIter *parent (void){
    >
    > /* Le tableau suivant va nous permettre de stocker la profondeur de
    >
    > l'appel, l'iter parent et l'iter en cours */
    >
    > if(iterArray->len==0) return NULL;
    >
    > return (g_array_index(iterArray,t_couche,0)).parent;
    >
    > }
    >
    >
    > I can't guess why the compiler print the warning. can you help me ?
    >
    See above.

    HTH,
    --ag

    -- 
    Artie Gold -- Austin, Texas
    "Yeah. It's an urban legend. But it's a *great* urban legend!"
    

  • Next message: spike: "Search a binary file for a string... again! (its to slow)"

    Relevant Pages

    • Re: Parameter Name Warning?
      ... the names on the declarations do not matter, it should perhaps give a warning regarding different names being used. ... > there is more to those names than just what the compiler does with them. ... > You know only what you get in the header. ... >>> int main ...
      (microsoft.public.vc.language)
    • Re: is order urgent doubt
      ... Which *compiler* are you using? ... layout of the warning messages.) ... i = sizeof(long int); ... about the code in the editor vs. the code in the source file. ...
      (comp.lang.c)
    • Re: Whats the deal with size_t?
      ... ES> allowed to emit diagnostics that C doesn't require. ... in warning about a signed to unsigned conversion. ... a size_t to an int it is quite justified in warning about the reverse, ... The compiler is also quite justified in warning if you use a signed ...
      (comp.lang.c)
    • Re: Compendiums of compiler warning/error messages mapped to actual code problems?
      ... The general problem is of course that the compiler messages must be short, and that tends to make them so cryptic that it isn't always immediately obvious what the problem is. ... int this; ... Warning twarn.c: ...
      (comp.lang.c)
    • Re: matrix stuff (solving b = A*x) --> using numerical recipes
      ... but then I removed it since I couldn't see any compiler warnings/errors without stdio.h). ... turn the warning level up to the maximum ... void banmul(float **a, unsigned long n, int left, int right, float x, float b); ...
      (comp.lang.c)