that's the code:
static inline void
shrinkData(const vector<Data> &data, unsigned short shrinkType){
#define CASE_N(N) \
case(N): \
ptr = MemoryManager::requestMemory(n*sizeof(ShrinkData<N>)); \
for(int i=0; i<n; i++){ \
new(ptr) ShrinkData<N>(data[i]); \
ptr+=sizeof(ShrinkData<N>); \
} \
return;
int n = data.size();
char* ptr;
switch(shrinkType){
case(0):
return;
CASE_N(1)
CASE_N(2)
CASE_N(3)
....
CASE_N(255)
}
now I get a fatal "error C1061: compiler limit : blocks nested too deeply" on line CASE_N(124)
can someone please tell me why this happens? actually the nesting should not be deeper than 2, no?
Thanks!
//edit: the requested constructor (the constructor works just fine without this switch function)
enum {//maximally 16 to fit in a unsigned short!
EID_POSITION = 1, //bit1
EID_T = 2, //bit2
EID_GEOMNORMAL = 4, //bit3
EID_NORMAL = 8, //bit4
EID_TANGENTS = 16, //bit5
EID_TEXCOORDS = 32, //bit6
EID_RAYDIR = 64, //bit7
EID_RECURSIONDEPTH = 128 //bit8
};
template<unsigned, unsigned>
struct IDataMember{
IDataMember(){}
IDataMember(const Data &iData){}
};
template<>
struct IDataMember<EID_POSITION, EID_POSITION>{
IDataMember(): position(Vector3(0,0,0)){}
IDataMember(const Data &iData):position(iData.position){}
Vector3 position;
};
... the same kind of template specialisation for each type in the enums...
template<unsigned members>
struct ShrinkData
:public IDataMember<members & EID_POSITION, EID_POSITION>
,public IDataMember<members & EID_T, EID_T>
,public IDataMember<members & EID_GEOMNORMAL, EID_GEOMNORMAL>
,public IDataMember<members & EID_NORMAL, EID_NORMAL>
,public IDataMember<members & EID_TANGENTS, EID_TANGENTS>
,public IDataMember<members & EID_TEXCOORDS, EID_TEXCOORDS>
,public IDataMember<members & EID_RAYDIR, EID_RAYDIR>
,public IDataMember<members & EID_RECURSIONDEPTH, EID_RECURSIONDEPTH>
{
ShrinkData()
:IDataMember<members & EID_POSITION, EID_POSITION>()
,IDataMember<members & EID_T, EID_T>()
,IDataMember<members & EID_GEOMNORMAL, EID_GEOMNORMAL>()
,IDataMember<members & EID_NORMAL, EID_NORMAL>()
,IDataMember<members & EID_TANGENTS, EID_TANGENTS>()
,IDataMember<members & EID_TEXCOORDS, EID_TEXCOORDS>()
,IDataMember<members & EID_RAYDIR, EID_RAYDIR>()
,IDataMember<members & EID_RECURSIONDEPTH, EID_RECURSIONDEPTH>(){}
ShrinkData(const Data &iData)
:IDataMember<members & EID_POSITION, EID_POSITION>(iData)
,IDataMember<members & EID_T, EID_T>(iData)
,IDataMember<members & EID_GEOMNORMAL, EID_GEOMNORMAL>(iData)
,IDataMember<members & EID_NORMAL, EID_NORMAL>(iData)
,IDataMember<members & EID_TANGENTS, EID_TANGENTS>(iData)
,IDataMember<members & EID_TEXCOORDS, EID_TEXCOORDS>(iData)
,IDataMember<members & EID_RAYDIR, EID_RAYDIR>(iData)
,IDataMember<members & EID_RECURSIONDEPTH, EID_RECURSIONDEPTH>(iData){}
};