Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
[Resolved]: Integration fails compiling with VS2008 http://www.volumesoffun.com/phpBB3/viewtopic.php?f=15&t=258 |
Page 1 of 2 |
Author: | DragonM [ Thu Sep 01, 2011 8:23 pm ] |
Post subject: | [Resolved]: Integration fails compiling with VS2008 |
The library itself builds fine, but LargeVolume can't be instantiated. In fact, LargeVolume.h can't even be included. The attempt causes an internal compiler error. Here's the offending code from LargeVolumeSampler.inl: Code: template <typename VoxelType> LargeVolume<VoxelType>::Sampler::Sampler(LargeVolume<VoxelType>* volume) :Volume<VoxelType>::template Sampler< LargeVolume<VoxelType> >(volume) { } The internal compiler error can be eliminated by modifying it to: Code: template <typename VoxelType> LargeVolume<VoxelType>::Sampler<VoxelType>::Sampler(LargeVolume<VoxelType>* volume) :Volume<VoxelType>::template Sampler< LargeVolume<VoxelType> >(volume) { } But that version still doesn't compile. Here's the warnings and errors: Code: C:\Dev\polyvox\library\PolyVoxCore\include\PolyVoxCore/LargeVolumeSampler.inl(39) : warning C4346: 'PolyVox::LargeVolume<VoxelType>::Sampler' : dependent name is not a type 1> prefix with 'typename' to indicate a type 1>C:\Dev\polyvox\library\PolyVoxCore\include\PolyVoxCore/LargeVolumeSampler.inl(39) : error C2143: syntax error : missing ';' before '<' 1>C:\Dev\polyvox\library\PolyVoxCore\include\PolyVoxCore/LargeVolumeSampler.inl(39) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Dev\polyvox\library\PolyVoxCore\include\PolyVoxCore/LargeVolumeSampler.inl(39) : error C2888: 'LargeVolume<VoxelType>::Sampler Sampler' : symbol cannot be defined within namespace 'PolyVox' 1>C:\Dev\polyvox\library\PolyVoxCore\include\PolyVoxCore/LargeVolumeSampler.inl(39) : fatal error C1903: unable to recover from previous error(s); stopping compilation Following the advice of the warning has no effect. All five unprefixed occurrences of VoxelType can be prefixed with typename and the results are unchanged. Nested template class inheritance strangles VS2008, it would seem. Unfortunately I can't guess which type specifier it's having trouble with. (Removing the initializer entirely has no effect on the results either, incidentally.) Little help? |
Author: | David Williams [ Thu Sep 01, 2011 9:32 pm ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
I assume you are using the latest version from Git? Since the last snapshot I have been refactoring the code so the the various volume classes derive from a common base, and the use of nested templated inheritance has indeed caused a few headaches. The current code builds on both VS2010 and GCC, but I haven't tested other compilers. Before we go any further, can you confirm whether the other volume classes cause the same problem (RawVolume and SimpleVolume)? |
Author: | David Williams [ Thu Sep 01, 2011 9:53 pm ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
DragonM wrote: The internal compiler error can be eliminated by modifying it to: Code: template <typename VoxelType> LargeVolume<VoxelType>::Sampler<VoxelType>::Sampler(LargeVolume<VoxelType>* volume) :Volume<VoxelType>::template Sampler< LargeVolume<VoxelType> >(volume) { } Actually I don't think you're fixing anything there. I tried the same change on VS2010 and it also gives compiler errors, which presumably the prevent the internal compiler error from occuring. Typing any invalid syntax would probably have the same effect. |
Author: | David Williams [ Thu Sep 01, 2011 9:56 pm ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
Also, I had to do a weird trick with typedef's to get it working on both VS2010 and GCC. Maybe it's relevent or you can do something similar: Code: 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> > The webpagelinked from that comment also has a much simplified example which you could try in VS2008... might be a different problem though. |
Author: | DragonM [ Fri Sep 02, 2011 12:17 am ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
David Williams wrote: DragonM wrote: The internal compiler error can be eliminated by modifying it to: Code: template <typename VoxelType> LargeVolume<VoxelType>::Sampler<VoxelType>::Sampler(LargeVolume<VoxelType>* volume) :Volume<VoxelType>::template Sampler< LargeVolume<VoxelType> >(volume) { } Actually I don't think you're fixing anything there. I tried the same change on VS2010 and it also gives compiler errors, which presumably the prevent the internal compiler error from occuring. Typing any invalid syntax would probably have the same effect. MSDN wrote: Note that just as with any template class member function, the definition of the class's constructor member function includes the template argument list twice. Of course, just because Microsoft says it's so doesn't make it so...
|
Author: | DragonM [ Fri Sep 02, 2011 12:31 am ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
David Williams wrote: I assume you are using the latest version from Git? Since the last snapshot I have been refactoring the code so the the various volume classes derive from a common base, and the use of nested templated inheritance has indeed caused a few headaches. The current code builds on both VS2010 and GCC, but I haven't tested other compilers. Yes, latest Git.Before we go any further, can you confirm whether the other volume classes cause the same problem (RawVolume and SimpleVolume)? Bizarrely, #including RawVolume.h and NOT including either ForwardDeclarations or LargeVolume.h, I get the LargeVolume Sampler errors reported in my first post (using my reported modification). No mention of RawVolume. Without my modification, I get an internal compiler error. Same for SimpleVolume. |
Author: | DragonM [ Fri Sep 02, 2011 1:08 am ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
David Williams wrote: Also, I had to do a weird trick with typedef's to get it working on both VS2010 and GCC. Maybe it's relevent or you can do something similar: Code: 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> > The webpagelinked from that comment also has a much simplified example which you could try in VS2008... might be a different problem though. I did notice the typedef trick. If it's applicable, I fail to see how. Certainly creating typedef LargeVolume<VoxelType> LargeVolumeOfVoxelType and using it in either of the two possible locations in the code did me no good. The typedef can't be resolved as a class or namespace, so it fails to compile, for different reasons. Creating typedef Volume<VoxelType>::Sampler SamplerOfVoxelType has the same problem. The C++ FAQ has a discussion of dependent and nondependent names. Unfortunately the sample doesn't appear to be applicable. In my professional opinion, that thing you are doing, you shouldn't be doing. When two or more compilers can't parse the code in the same way, you run the risk that two or more compilers are going to fail to generate correct ASM. Writing code that's hard up against the bleeding edge of the language standard (or in your case, hanging over the bleeding edge waving your arms saying "Look at me, no hands!") means it's unlikely to be portable, generally usable code. Portable code is good practice. Unportable code usually means you're doing something you shouldn't. |
Author: | David Williams [ Fri Sep 02, 2011 9:57 pm ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
DragonM wrote: Bizarrely, #including RawVolume.h and NOT including either ForwardDeclarations or LargeVolume.h, I get the LargeVolume Sampler errors reported in my first post (using my reported modification). No mention of RawVolume. Without my modification, I get an internal compiler error. That sounds a little strange - I will try to find some time to test this for myself. I don't currently have VS2008 installed but can probably download the express version. However, I'm on a 5Gb/month download limit so I have to be a little careful. I think I can spare it though and it would be good to test. DragonM wrote: In my professional opinion, that thing you are doing, you shouldn't be doing. When two or more compilers can't parse the code in the same way, you run the risk that two or more compilers are going to fail to generate correct ASM. Writing code that's hard up against the bleeding edge of the language standard (or in your case, hanging over the bleeding edge waving your arms saying "Look at me, no hands!") means it's unlikely to be portable, generally usable code. Portable code is good practice. Unportable code usually means you're doing something you shouldn't. I will freely admit that I'm pushing the compilers to the limit and also my own knowledge of template programming. Actually I've just been trying to see what I can do, and am aware of some issues which is why I haven't released a stable snapshot yet. That said, I do think the structure I'm aiming for makes sense so if it did compile more reliably that would be great I'll have a play with it and maybe relax a constraint. I'm not sure which one causes most problems out of 'nested', 'templated', or 'inherited' for these classes but I can probably remove the 'inherited' aspect most easily. In the mean time, you can either use the last snapshot, or this version from Git which is from before I started this refactoring. I don't know how you check out a specific version from Git - you're on your own there But it does include the VolumeResampler though the example is currently quite messy. |
Author: | DragonM [ Sat Sep 03, 2011 3:58 am ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
David Williams wrote: DragonM wrote: Bizarrely, #including RawVolume.h and NOT including either ForwardDeclarations or LargeVolume.h, I get the LargeVolume Sampler errors reported in my first post (using my reported modification). No mention of RawVolume. Without my modification, I get an internal compiler error. That sounds a little strange - I will try to find some time to test this for myself. I don't currently have VS2008 installed but can probably download the express version. However, I'm on a 5Gb/month download limit so I have to be a little careful. I think I can spare it though and it would be good to test. David Williams wrote: DragonM wrote: In my professional opinion, that thing you are doing, you shouldn't be doing. When two or more compilers can't parse the code in the same way, you run the risk that two or more compilers are going to fail to generate correct ASM. Writing code that's hard up against the bleeding edge of the language standard (or in your case, hanging over the bleeding edge waving your arms saying "Look at me, no hands!") means it's unlikely to be portable, generally usable code. Portable code is good practice. Unportable code usually means you're doing something you shouldn't. I will freely admit that I'm pushing the compilers to the limit and also my own knowledge of template programming. Actually I've just been trying to see what I can do, and am aware of some issues which is why I haven't released a stable snapshot yet. That said, I do think the structure I'm aiming for makes sense so if it did compile more reliably that would be great I'll have a play with it and maybe relax a constraint. I'm not sure which one causes most problems out of 'nested', 'templated', or 'inherited' for these classes but I can probably remove the 'inherited' aspect most easily. In the mean time, you can either use the last snapshot, or this version from Git which is from before I started this refactoring. I don't know how you check out a specific version from Git - you're on your own there But it does include the VolumeResampler though the example is currently quite messy. |
Author: | David Williams [ Sat Sep 03, 2011 11:21 am ] |
Post subject: | Re: Integration fails compiling with Visual Studio 2008 |
Ok, I've grabbed a copy of VS2008 Express (it was only 90mb) and done some investigation. DragonM wrote: David Williams wrote: DragonM wrote: Bizarrely, #including RawVolume.h and NOT including either ForwardDeclarations or LargeVolume.h, I get the LargeVolume Sampler errors reported in my first post (using my reported modification). No mention of RawVolume. Without my modification, I get an internal compiler error. That sounds a little strange - I will try to find some time to test this for myself. I don't currently have VS2008 installed but can probably download the express version. However, I'm on a 5Gb/month download limit so I have to be a little careful. I think I can spare it though and it would be good to test. This behaviour is (at least mostly) occuring because the #includes are a mess in the code. LargeVolume.h is included in a lot of places it shouldn't be. Actually I remember noticing this a few weeks ago when doing the volume refactoring, so I'll be sure to get it tidied up. DragonM wrote: The library itself builds fine, but LargeVolume can't be instantiated. In fact, LargeVolume.h can't even be included. The attempt causes an internal compiler error. I managed to reproduce this quite easily, and it was fixed by removing some inheritance as previsouly suggested. However, I then noticed something interesting - when I checked out a fresh version of PolyVox and used CMake to generate the solution files it all compiled and ran perfectly, including the examples. However, the external test project was still giving an internal compiler error. Eventually I started comparing compiler options and identified the '/Gm' switch as being the problem. This corresponds to 'Enabled Minimal Rebuild' and is on by default in a VS generated project but off in a CMake generated project. Removing this flag from the test project does seem to allow it to build correctly. There is some chance that this issue is a result of the header file mess mentioned above. From the MSDN page: MSDN wrote: Minimal rebuild relies on class definitions not changing between include files. Class definitions must be global for a project (there should be only one definition of a given class), because the dependency information in the .idb file is created for the entire project. If you have more than one definition for a class in your project, disable minimal rebuild. At any rate I think I should first sort out the header dependancies and then see whether this '/Gm' switch is still a problem. |
Page 1 of 2 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |