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 14:58:14
|
Your second solution, the one with // main.h extern int some_important_variable; // main.cpp int some_important_variable; should work too - it's the normal way of accessing a variable between multiple modules. I assume that all you needed to to was to perform a full rebuild, since the extrafunctions.cpp already contained it's own copy of the variable. /Per W On Sun, 27 Jul 2003, FerretallicA wrote: > Oo oi, > > OK got it working... I tried the following code and it made no difference, > but I tried doing a clean build and now it's worked. The solution is basic, > 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. > > -FerretallicA > > ----- Original Message ----- > From: "FerretallicA" <fer...@ho...> > To: "Dev-C++ Users Mailing List" <dev...@li...> > Sent: Sunday, July 27, 2003 4:03 PM > Subject: [Dev-C++] Multiply-included header problem > > > Oo oi, > > I have a bit of a dilemma, albiet a seemingly simplistic one... > Say I have 3 files as follows- > > > MAIN.CPP > #include "main.h" > > EXTRAFUNCTIONS.CPP > #include "main.h" > > MAIN.H > int some_variable_important_to_lots_of_functions; > > > I keep getting errors that some_variable_important_to_lots_of_functions is > being redefined. I have tried the "#pragma once" solution which worked with > Visual C++ but it doesn't seem to work in Dev-C++. I tried > the following- > > > MAIN.CPP > #include "main.h" > int some_variable_important_to_lots_of_functions; > > EXTRAFUNCTIONS.CPP > #include "main.h" > > MAIN.H > extern int some_variable_important_to_lots_of_functions; > > > Still the same problem. Does anyone know of a solution to this? Is this some > mistake I am making, a problem with Dev-C++'s compiler, or what? > > -FerretallicA > > > ------------------------------------------------------- > 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 > > > > ------------------------------------------------------- > 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 > |