|  | error: implicit declaration of function `func_name' |  | |
| | | DanielJohnson |  |
| Posted: Tue Jun 17, 2008 9:37 pm Post subject: error: implicit declaration of function `func_name' |  |
I call a function which is named as func_name in file /source/folderA/ fileA.c.
The actual function definition is in /source/folderB/fileB.c.
And I get this error.
warning: implicit declaration of function `func_name' ***Error Code 1
I know that I have to include the file in fileA.c but the library in which I am working on is clean, i.e. there are no cross includes like that.
Any other option to do that. |
| |
| | | santosh |  |
| Posted: Tue Jun 17, 2008 9:37 pm Post subject: Re: error: implicit declaration of function `func_name' |  |
DanielJohnson wrote:
| Quote: | I call a function which is named as func_name in file /source/folderA/ fileA.c.
The actual function definition is in /source/folderB/fileB.c.
And I get this error.
warning: implicit declaration of function `func_name' ***Error Code 1
I know that I have to include the file in fileA.c but the library in which I am working on is clean, i.e. there are no cross includes like that.
Any other option to do that.
|
Yes. Include the correct prototype for func_name in a header and include that header in fileA.c |
| |
| | | Richard Tobin |  |
| Posted: Tue Jun 17, 2008 9:37 pm Post subject: Re: error: implicit declaration of function `func_name' |  |
In article <72a03b94-3f8c-4068-a29e-e019f53124d0@j33g2000pri.googlegroups.com>, DanielJohnson <diffuser78@gmail.com> wrote:
| Quote: | I know that I have to include the file in fileA.c but the library in which I am working on is clean, i.e. there are no cross includes like that.
|
Why do you think it is "unclean" to include the necessary header?
If your program has a structure you consider unclean, then restructure the program. Don't try to hide the dirtiness by not including the necessary headers.
-- Richard -- In the selection of the two characters immediately succeeding the numeral 9, consideration shall be given to their replacement by the graphics 10 and 11 to facilitate the adoption of the code in the sterling monetary area. (X3.4-1963) |
| |
| | | rahul |  |
| Posted: Wed Jun 18, 2008 6:30 am Post subject: Re: error: implicit declaration of function `func_name' |  |
| |  | |
On Jun 18, 2:37 am, DanielJohnson <diffuse...@gmail.com> wrote:
| Quote: | I call a function which is named as func_name in file /source/folderA/ fileA.c.
The actual function definition is in /source/folderB/fileB.c.
And I get this error.
warning: implicit declaration of function `func_name' ***Error Code 1
|
If your function is "int foo(int a)" either declare that in a header and include the header: /* foo.h */ #ifndef _FOO_H #define _FOO_H int foo(int a); #endif
/* fileA.c */ #include "foo.h"
or declare the function in your source file: /* fileA.c */ extern int foo(int );
Including header is cleaner than the extern declarations. If the function prototype is not encountered, a standard complying compiler is required to show diagnostics. Before standardization, prototypes were not required and functions were assumed to be returning int with variable number of arguments.
| Quote: | I know that I have to include the file in fileA.c but the library in You don't include the .c files but the header files. which I am working on is clean, i.e. there are no cross includes like that.
What do you mean by a cross include? |
|
| |
| | | santosh |  |
| Posted: Wed Jun 18, 2008 9:10 am Post subject: Re: error: implicit declaration of function `func_name' |  |
rahul wrote:
<snip>
| Quote: | Before standardization, prototypes were not required and functions were assumed to be returning int with variable number of arguments.
|
I suppose it would be more correct to say that before standardisation function declarations specified the function name and return type and that it took unspecified arguments.
<snip> |
| |
| | | rahul |  |
| Posted: Wed Jun 18, 2008 11:43 am Post subject: Re: error: implicit declaration of function `func_name' |  |
On Jun 18, 3:58 pm, santosh <santosh....@gmail.com> wrote:
| Quote: | rahul wrote:
snip
Before standardization, prototypes were not required and functions were assumed to be returning int with variable number of arguments.
I suppose it would be more correct to say that before standardisation function declarations specified the function name and return type and that it took unspecified arguments.
snip
|
Yup...that would be more appropriate... |
| |
|
|