gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Multiple definitions

#46070 - whodoo - Sun Jun 19, 2005 3:14 pm

I have a problem I've been struggling with for a long time now. Suppose I have a header file containing definitions, variables and typedefs. I want to use this file in the entire program.

SupposeI have another header file (with some prototypes) where I need this definitions and variables. This mean that I have to include the other header file in this header.

Then, when I'm including them both header files in my "main file" I get "multiple definitions"-errors. How can I solve this?

#46071 - strager - Sun Jun 19, 2005 3:25 pm

Code:

#ifndef FILENAME_H_INCLUDE
#define FILENAME_H_INCLUDE

[includes here]
[defenitions here]

#endif /* FILENAME_H_INCLUDE */


That's how it should be set up for ALL header files.

#46072 - Kyoufu Kawa - Sun Jun 19, 2005 3:35 pm

Even though it's for a Windoze project, I have one with __BEEN_THERE_DONE_THAT as the flag :P