Jump to content
Sign in to follow this  
MrWilliams

'function Redefinition:....'

Recommended Posts

Hi,

I've had my program building ok up til now, but i've tried to tidy the code up by moving my common functions and variables into a header file.

Now the code compiles ok, but the linker rejects it, repeating:

 

'[file name].h Function redefinition:[funciton name] in [file name].h'

 

about 4 times for each function.

I've only defined each function once as far as i can see. Can anyone shed any light on this problem, or should i just go back to how i was before.

 

Thanks

 

Simon.

Share this post


Link to post
Share on other sites

Simon,

 

Sounds like the problem is you move the whole function into the header file, and then include them in more than one source file. It just like having the same function declared multiple times!

 

What you need to do is only add the function prototype to the header and put the actual function body in another file eg

 

void foo( char x ); // put in header file

 

void foo( char ) // put in another source file (normally same name as header)

{

...

}

 

hope that helps.

 

Regards

Dave

Share this post


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...
Sign in to follow this  

×
×
  • Create New...