Quickfix:
Make sure your functions are declared once and only once before calling them. For example, change:
main(){ myfun(3.4); }
double myfun(double x){ return x; }
To:
double myfun(double x){ return x; }
main(){ myfun(3.4); }
Or add a separate function declaration:
double myfun(double x);
main(){ myfun(3.4); }
double myfun(double x){ return x; }
Possible causes of the error
- Function called before declaration
- A specific function overrides the function declared in the included header.
- The function was defined twice in one file
- Declaration and definition do not comply
- Conflict declaration in included headers
What is really going on
error: conflicting types for ‘foo’ , .
, , , , :
int foo(){return 1;}
double foo(){return 1.0;}
, GCC :
foo.c:5:8: error: conflicting types for ‘foo’
double foo(){return 1.0;}
^
foo.c:4:5: note: previous definition of ‘foo’ was here
int foo(){return 1;}
^
,
double foo(){return 1;}
double foo(){return 1.0;}
'redefinition':
foo.c:5:8: error: redefinition of ‘foo’
double foo(){return 1.0;}
^
foo.c:4:8: note: previous definition of ‘foo’ was here
double foo(){return 1;}
^
, error: conflicting types for ‘foo’?
main(){ foo(); }
double foo(){ return 1.0; }
.
foo() main, foo of int foo(). , , , ( ).
, , , C (, , Objective-C) , . , , , , . , C99.
, , , .