why Multiple define error ...

This is a discussion on why Multiple define error ... within the C Programming forums, part of the General Programming Boards category; hi,
i have created a header file with guard and it looks like
somehead.h as
.
.
some #defines
.
...

macros (created with #define) are expanded by the preprocessor doing text substitution. They never exist as symbols in an executable, so the linker has no reason to complain.

With integer definitions like;

Code:

const long int slim_nil = 0;

a const int is declared and defined. If you place that in a header file that is #include'd in multiple source files, those source files are compiled into object files and each object file has a copy. The linker sees the variable definition in multiple object files, and complains about multiple definitions.

The fix is to use;

Code:

extern const long int slim_nil; /* A declaration, not a definition */

in your header file. And in EXACTLY one source file in your project which #include's that header, place this somewhere AFTER the #include directive.