Re: [Dev-C++] Multiply-included header problem
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-07-27 15:04:11
|
But that's not what FerretallicA wanted. He tried to implement main.h: #ifndef _MAIN_H_ ... #if INSTANTIATE_GLOBALS #define GLOBAL #else #define GLOBAL extern #endif GLOBAL int some_important_variable; #endif _MAIN_H_ main.cpp: #define INSTANTIATE_GLOBALS #include "main.h" // Instantiate needed global variables. extrafunctions.cpp: #include "main.h" // Just thell what global variables are available. Renaming PRAGMAONCE to _MAIN_H would still result in all source files including main.h getting a copy of the global variable. /Per W On Sun, 27 Jul 2003, OROSZI Bal=E1zs wrote: > FerretallicA wrote: > > Oo oi, > > > > OK got it working... I tried the following code and it made no differen= ce, > > but I tried doing a clean build and now it's worked. The solution is ba= sic, > > but here it is anyway for those who might run into this problem at some > > point. > > > > MAIN.H > > #ifndef PRAGMAONCE > > #define PRAGMAONCE > > int some_important_variable; > > #endif > > > > > > PRAGMAONCE can be renamed to whatever you feel like if you really want. > > It actually SHOULD be renamed, and it should also be unique in each > header file. Because if not, some header files will not be included. > So I suggest, you name it something like this: > > #ifndef _MAIN_H_ > #define _MAIN_H_ > int some_important_variable; > #endif > > -- > Greetings, > Bal=E1zs > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/= 01 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |