Jump to content
  • Advertisement
Sign in to follow this  
freeworld

[vs c++] What causes this error?

This topic is 2641 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just out of curiosity, could someone explain to me what is going on behind the scenes that causes this error to happen.

If I have a header with a function defined within, without any prototype declaration. If I include the header in more than one file I get an error saying that it's being defined more than once "multiple symbol defined". But I thought using the ifndef / define flags should stop the compiler from processing that code over again... but then again I really don't know much about what the compiler actually is doing.

psudeo header example

#ifndef _H
#define _H

void MyFunction() {
... do something...
};

#endif


I'm assuming this is special to C++, or any other language that doesn't do incremental builds such as C# or JAVA?

Share this post


Link to post
Share on other sites
Advertisement
The preprocessor is just a text replacement processor. You end up with more than one C++ source file with the exact same function definition, and when you try to link the compiled objects together, ka-POW, duplicate symbols.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!