Jump to content

Implementation File, Function Body Error


Recommended Posts

High everybody. I am wondering if anybody has had trouble with building a header file defining functions. Some of my programs are becoming large so I need to distribute the functions. I'm getting this general error when compiling.

 

" error: Function 'some_function' already has a body"

 

When it is clear I have defined the function only once!

 

I am using this general format.

 

////in the header file

 

#ifndef _HEADER_H_

#define _HEADER_H_

 

#include "implemenation_file.c"

 

void some_function(var);

 

#endif

 

 

////in the implementation file

 

#include <system.h>

#include "header.h"

 

void some_function(var)

{ }

 

Any suggestions??

 

Thanks

Link to post
Share on other sites

A little weird, the header includes the c file which includes the header.

You are prototyping some_function after its body has been defined in implemenation_file.c

 

#ifndef _HEADER_H_

#define _HEADER_H_

 

#include "implemenation_file.c"

 

void some_function(var);

 

#endif

 

try

 

#ifndef _HEADER_H_

#define _HEADER_H_

 

void some_function(var);

 

#include "implemenation_file.c"

 

 

#endif

 

though I have to say the whole scheme is rather ghastly and will probably fall over at linking due to

some_function being included in more than one .obj file

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...