List Info

Thread: Re: Same project but different files included




Re: Same project but different files included
country flaguser name
United States
2007-05-31 03:12:36

--- In anthemion-devtools%40yahoogroups.com">anthemion-devtoolsyahoogroups.com, YAP <x112358...> wrote:
&gt;
> Thanks Dave for all the work you spent on this (appreciated).
>;
> I work in the way you describe today. For this project I use Visual
C++ for
> WIN32 and GCC for Unix.
&gt;
> As this is a quite a large project there is many ifdefs for platform
> dependent things but for some functionality the implementions are so
> different that the code is in a seperate h/cpp file pairs for each
>; platform. Yes I know it would have been possible to put them in the
same
> files and use ifdefs but separate them make the code easier to
maintain and
> look nice.
&gt;
> So to be clear
&gt;
> - On Unix I need to compile files a.cpp, b.cpp, d.cpp amd x.cpp to
form the
> executable aaaa
>; - On Windows I need to compile files a.cpp, b.cpp, d.cpp amd y.cpp
form the
> executable aaaa.exe
>
> Cheers
&gt; /Ake
>;
> On 5/31/07, Dave Silvia <dsilvia...> wrote:
&gt; >
>; > > -- On Wed, 30 May 2007 22:39:29 +0200 YAP wrote -- I have a
project
> > > which is built for Windows and Unix. For some parts of this project
> > > different files is used for each environment. How is this best
>; > > handled in DialogBlocks?
> > >
>; > > One obvious way to solve this is to create two projects. One for
> > > Unix and one for Windows which overlaps. A better way in my opinion
> > > was if the source section could have some environment under
&gt; > > sections also which was hooked to the "configurations&quot; settings.
> > >
>; > > This is still my # 1 favorite tool!
&gt; > >
>; > > Cheers /Ake
>; > >
>; >
>; > Hi!
> >
>; > I'm only guessing, since you don't mention platform specifics,
> > compilers, or DB/wxWidgets versions, that you're using the current
> > DB/wxWidgets and the same compiler on both platforms? (else, there is
> > no conflict!;)
> >
>; > >> A better way in my opinion was if the source section could have
>; > >> some environment under sections also which was hooked to the
> > >> "configurations&quot; settings.
> >
>; > Just for grins, let's say you're using GCC on both platforms. You can
> > keep platform specific details separate by using the Add button in
> > Build>Configurations>Compiler Configurations:
>; >
>; >
>; >
>; > You then get:
>; >
>; >
>; >
>; > Check the box Debug version, insert Unix in front of GCC Debug, and
> > click OK.
> >
>; > Select Add again, and this time:
&gt; >
>; >
>; >
>; > only insert Unix in front of GCC Release and click OK.
> >
>; > Then do similarly for Windows, inserting Windows in front of GCC
> > Debug/Release.
> >
>; > There should be no conflicts then, as DB will generate appropriate
> > makefiles on each platform. If the includes you need are in addition
> > to platform headers (I assume they are, by implication from your
>; > post), the Include path would be set to:
> >
>; >
>; >
>; > for Unix and:
>; >
>; >
>; >
>; > for Windows.
> >
>; > If the specific files are what you're changing from one platform to
> > another, the standard method is to #ifdef ... #else ... #endif around
&gt; > the include files in the code, i.e.:
&gt; >
>; > #ifdef MyWindows
> > #include "myWindows.h&quot;
> > #else
&gt; > #include "myUnix.h"
> > #endif
&gt; >
>; > and have DB define MyWindows for Windows GCC Debug/Release:
> >
>; >
>; >
>; > with -DMyWindows in the Debug flags.
&gt; >
>; > Lastly, you'd want to have separate makefiles, so:
> >
>; >
>; >
>; > and:
>; >
>; >
>; >
>; > In this way, you have only one project for multiple builds.
> >
>; > I'm attaching a .pjd for reference.
> >
>; > HTH:
>; >
>; > thx, Dave S.
> ---
> Ake Hedman (YAP - Yet Another Programmer)

> - On Unix I need to compile files a.cpp, b.cpp, d.cpp amd x.cpp to
form the
> executable aaaa
>; - On Windows I need to compile files a.cpp, b.cpp, d.cpp amd y.cpp
form the
> executable aaaa.exe

Hi!

Hmm...

Is there a way you can put these files into an include file, i.e.:

platformSrcs.h

#ifdef MyWindows
#include "myWindowsa.cpp"
#include "myWindowsb.cpp"
#include "myWindowsd.cpp"
#include "myWindowsy.cpp"
#else
#include "myUnixa.cpp&quot;
#include "myUnixb.cpp&quot;
#include "myUnixd.cpp&quot;
#include "myUnixx.cpp&quot;
#endif

or if they need separate files, just put each in a file with the
#ifdef... #else ... #endif.

platformA.h
#ifdef MyWindows
#include "myWindowsa.cpp"
#else
#include "myUnixa.cpp&quot;
#endif

platformB.h
#ifdef MyWindows
#include "myWindowsb.cpp"
#else
#include "myUnixb.cpp&quot;
#endif

platformD.h
#ifdef MyWindows
#include "myWindowsd.cpp"
#else
#include "myUnixd.cpp&quot;
#endif

platformXY.h
#ifdef MyWindows
#include "myWindowsy.cpp"
#else
#include "myUnixx.cpp&quot;
#endif

In that way, you can have your cake and eat it, too! (to coin a
phrase!;)

Anyway, that's what I'd do. It should work just fine.

HTH:

thx,
Dave S.

__._,_.___
.

__,_._,___
Re: Re: Same project but different files included
country flaguser name
United States
2007-05-31 03:23:26

Excellent! Thanks! Have never thought about myself.....

Cheers
/Ake

On 5/31/07, ddotedotsdot < dsilviamchsi.com">dsilviamchsi.com > wrote:

--- In anthemion-devtools%40yahoogroups.com" target="_blank">anthemion-devtoolsyahoogroups.com, YAP <x112358...> wrote:
>
>; Thanks Dave for all the work you spent on this (appreciated).
>;
> I work in the way you describe today. For this project I use Visual
C++ for
> WIN32 and GCC for Unix.
&gt;
> As this is a quite a large project there is many ifdefs for platform
> dependent things but for some functionality the implementions are so
> different that the code is in a seperate h/cpp file pairs for each
>; platform. Yes I know it would have been possible to put them in the
same
> files and use ifdefs but separate them make the code easier to
maintain and
> look nice.
&gt;
> So to be clear
&gt;
> - On Unix I need to compile files a.cpp, b.cpp, d.cpp amd x.cpp to
form the
> executable aaaa
>; - On Windows I need to compile files a.cpp, b.cpp, d.cpp amd y.cpp
form the
> executable aaaa.exe
>
> Cheers
&gt; /Ake
>;

> On 5/31/07, Dave Silvia <dsilvia...> wrote:
&gt; >
>; > > -- On Wed, 30 May 2007 22:39:29 +0200 YAP wrote -- I have a
project
> > > which is built for Windows and Unix. For some parts of this project
> > > different files is used for each environment. How is this best
>; > > handled in DialogBlocks?
> > >
>; > > One obvious way to solve this is to create two projects. One for
> > > Unix and one for Windows which overlaps. A better way in my opinion
> > > was if the source section could have some environment under
&gt; > > sections also which was hooked to the "configurations&quot; settings.
> > >
>; > > This is still my # 1 favorite tool!
&gt; > >
>; > > Cheers /Ake
>; > >
>; >
>; > Hi!
> >
>; > I'm only guessing, since you don't mention platform specifics,
> > compilers, or DB/wxWidgets versions, that you're using the current
> > DB/wxWidgets and the same compiler on both platforms? (else, there is
> > no conflict!;)
> >
>; > >> A better way in my opinion was if the source section could have
>; > >> some environment under sections also which was hooked to the
> > >> "configurations&quot; settings.
> >
>; > Just for grins, let's say you're using GCC on both platforms. You can
> > keep platform specific details separate by using the Add button in
> > Build>Configurations>Compiler Configurations:
>; >
>; >
>; >
>; > You then get:
>; >
>; >
>; >
>; > Check the box Debug version, insert Unix in front of GCC Debug, and
> > click OK.
> >
>; > Select Add again, and this time:
&gt; >
>; >
>; >
>; > only insert Unix in front of GCC Release and click OK.
> >
>; > Then do similarly for Windows, inserting Windows in front of GCC
> > Debug/Release.
> >
>; > There should be no conflicts then, as DB will generate appropriate
> > makefiles on each platform. If the includes you need are in addition
> > to platform headers (I assume they are, by implication from your
>; > post), the Include path would be set to:
> >
>; >
>; >
>; > for Unix and:
>; >
>; >
>; >
>; > for Windows.
> >
>; > If the specific files are what you're changing from one platform to
> > another, the standard method is to #ifdef ... #else ... #endif around
&gt; > the include files in the code, i.e.:
&gt; >
>; > #ifdef MyWindows
> > #include "myWindows.h&quot;
> > #else
&gt; > #include "myUnix.h"
> > #endif
&gt; >
>; > and have DB define MyWindows for Windows GCC Debug/Release:
> >
>; >
>; >
>; > with -DMyWindows in the Debug flags.
&gt; >
>; > Lastly, you'd want to have separate makefiles, so:
> >
>; >
>; >
>; > and:
>; >
>; >
>; >
>; > In this way, you have only one project for multiple builds.
> >
>; > I'm attaching a .pjd for reference.
> >
>; > HTH:
>; >
>; > thx, Dave S.
> ---
> Ake Hedman (YAP - Yet Another Programmer)

> - On Unix I need to compile files a.cpp, b.cpp, d.cpp amd x.cpp to
form the
> executable aaaa
>; - On Windows I need to compile files a.cpp, b.cpp, d.cpp amd y.cpp
form the
> executable aaaa.exe

Hi!

Hmm...

Is there a way you can put these files into an include file, i.e.:

platformSrcs.h

#ifdef MyWindows
#include "myWindowsa.cpp"
#include "myWindowsb.cpp"
#include "myWindowsd.cpp"
#include "myWindowsy.cpp"
#else
#include "myUnixa.cpp&quot;
#include "myUnixb.cpp&quot;
#include "myUnixd.cpp&quot;
#include "myUnixx.cpp&quot;
#endif

or if they need separate files, just put each in a file with the
#ifdef... #else ... #endif.

platformA.h
#ifdef MyWindows
#include "myWindowsa.cpp"
#else
#include "myUnixa.cpp&quot;
#endif

platformB.h
#ifdef MyWindows
#include "myWindowsb.cpp"
#else
#include "myUnixb.cpp&quot;
#endif

platformD.h
#ifdef MyWindows
#include "myWindowsd.cpp"
#else
#include "myUnixd.cpp&quot;
#endif

platformXY.h
#ifdef MyWindows
#include "myWindowsy.cpp"
#else
#include "myUnixx.cpp&quot;
#endif

In that way, you can have your cake and eat it, too! (to coin a
phrase!;)

Anyway, that's what I'd do. It should work just fine.

HTH:

thx,
Dave S.




--
---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavagen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 0533 146
Company home: http://www.dofscandinavia.com&nbsp;   ;
Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.dofscandinavia.com/akhe
Automated home: http://www.vscp.org

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )