Replaced template 'hack' with preprocessor 'fix' to allow compilation on both GCC and Visual Studio. The previous approach was causing problems on VS2008.

This commit is contained in:
David Williams 2011-09-04 13:57:24 +01:00
parent 06cc2806dd
commit b84147f650
3 changed files with 36 additions and 6 deletions

View File

@ -153,8 +153,18 @@ namespace PolyVox
class LargeVolume : public Volume<VoxelType>
{
public:
typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
class Sampler : public VolumeOfVoxelType::template Sampler< LargeVolume<VoxelType> >
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
//in the future
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
//class Sampler : public VolumeOfVoxelType::template Sampler< LargeVolume<VoxelType> >
#if defined(_MSC_VER)
class Sampler : public Volume<VoxelType>::Sampler< LargeVolume<VoxelType> > //This line works on VS2010
#else
class Sampler : public Volume<VoxelType>::Sampler Nested< LargeVolume<VoxelType> > //This line works on GCC
#endif
{
public:
Sampler(LargeVolume<VoxelType>* volume);

View File

@ -42,8 +42,18 @@ namespace PolyVox
{
public:
#ifndef SWIG
typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume<VoxelType> >
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
//in the future
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
//class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume<VoxelType> >
#if defined(_MSC_VER)
class Sampler : public Volume<VoxelType>::Sampler< RawVolume<VoxelType> > //This line works on VS2010
#else
class Sampler : public Volume<VoxelType>::Sampler Nested< RawVolume<VoxelType> > //This line works on GCC
#endif
{
public:
Sampler(RawVolume<VoxelType>* volume);

View File

@ -67,8 +67,18 @@ namespace PolyVox
uint8_t m_uSideLengthPower;
};
typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
class Sampler : public VolumeOfVoxelType::template Sampler< SimpleVolume<VoxelType> >
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
//in the future
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
//class Sampler : public VolumeOfVoxelType::template Sampler< SimpleVolume<VoxelType> >
#if defined(_MSC_VER)
class Sampler : public Volume<VoxelType>::Sampler< SimpleVolume<VoxelType> > //This line works on VS2010
#else
class Sampler : public Volume<VoxelType>::Sampler Nested< SimpleVolume<VoxelType> > //This line works on GCC
#endif
{
public:
Sampler(SimpleVolume<VoxelType>* volume);