This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: problem with function declaration and definition mismatch using GCC


Hi,

    Sorry for my mistake,

    someone defined vol to *(pVol), so the code is OK.

2009/7/24 阎淼 <yanmiaobest@gmail.com>:
> Hi,
>
>  I am using GCC 4.1.2 on a project, the prototype and definition of a
> function is mismatch, but the programs
>
>  compiles and works fine,   how GCC compiles following code and checks
> the prototype ?
>
>  in file a.h :
>
>       typedef struct {...}  struct_b;
>
>       extern  int  func_A ( struct_a * socket, struct_b * flash);
>
>  in file a.c:
>
>       #include "a.h"
>
>       int func_A( struct_a * socket, struct_b vol)
>       {
>                 .....
>                 vol.read = read;
>                 vol.write = write;
>                 .....
>                 return 0;
>       }
>
> and another file b.c:
>
>      #include "a.h"
>
>      int func_B(.....)
>      {
>            struct_b flash;
>
>            func_A( ...,   &flash);
>
>
>            flash.read(xxx);
>      }
>
>
> GCC compiles this piece of code without warnings, and it works fine.
> But there is a  mismatch between declaration and definition  of
> func_A,
>
> should there be a warning ?  I compiled the code with -ansi and -Wall
> options.  And when I changed the prototype to
>
> extern  int  func_A ( struct_a * socket, struct_b * vol),   GCC gives
> a error saying conflicting types of func_A.
>
>
>
> Best Regards!
> Miao Yan
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]