Hello,
I have a header file x.h which is included by more than one *.c source files. This header file has some structure variables defined. I have put multiple inclusion prevention guard at the beginning of the header file as:
#ifndef X_H
#define X_H
...
..
//header file declarations and definitons.
#endif//X_H
On building I get linker errors related to Multiple definitions. I understand the problem.
Questions is :
1.) Won't a multiple inclusion prevention guard at the top of header file as I have, prevent multiple inclusions of the header file x.h and thereby avoid multiple definitions of the variables that are there in x.h??
2.) #pragma once does not work on this particular compiler, so what is the solution. Someone had posted this answer to a similar question. It doesnt seem to work for me. How does this solution work?
wishes,
-AD