Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » C

error: implicit declaration of function `func_name'

 
Jump to:  
 
DanielJohnson
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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
PostPosted: 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...
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

stroje Lechoń Jan wiersze spa breaks Bigudir bmw wrocław