Public Group

[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.

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.

 #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 on other sites
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.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633735
• Total Posts
3013593
×