function - Error in c programme conflicting types for xx and previous implicit declaration of xx was here -



function - Error in c programme conflicting types for xx and previous implicit declaration of xx was here -

suppose have file insert.c in 2 functions defined: 1.insert_after 2.insert_before

the definitions of these func this:

insert_after(arg1) { if(condition 1) { ......... } else insert_before(arg1); } insert_before(arg) { if(condition 1) { ......... } else insert_after(arg); }

now if file insert.c included in main.c , insert_after function called

# include "insert.c" int main() { insert_after(arg); homecoming 0; }

on compiling main.c using gcc,the next error encountered:

conflicting types ‘insert_before’

note: previous implicit declaration of ‘insert_before’ here

what wrong here , how avoid it?

this because don't declare prototypes functions. function has no prototype, default, has unknown set of arguments , returns int. not case insert_before.

create file insert.h in declare them:

#ifndef insert_h #define insert_h void insert_before(type_of_arg); void insert_after(type_of_arg); #endif /* insert_h */

and include file @ top of insert.c.

you should compile with:

gcc -wall -wstrict-prototypes -wmissing-prototypes -o progname insert.c main.c

c function

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -