|Re: [eigen] patches for EIGEN_STATIC_ASSERT|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] patches for EIGEN_STATIC_ASSERT
- From: Kenneth Riddile <kfriddile@xxxxxxxxx>
- Date: Thu, 18 Dec 2008 07:57:35 -0800 (PST)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=nfU8cRo2vd7JyMR1mjWLltQyNldjyl/d3S0aXjMmIV9u934gS59F6PhWL3LpiU7kzB4b0IuYq7rwdQTxtme1qOXyiXxYyjBJ3FgWJST0AqDe9+wISBv4xvmyJk3z69zxP6TyAb+irPiXIYJetCRn3vnks/JgreW0mwRa2xczL7E=;
> From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
> Subject: Re: [eigen] patches for EIGEN_STATIC_ASSERT
> To: eigen@xxxxxxxxxxxxxxxxxxx
> Date: Wednesday, December 17, 2008, 9:57 PM
> Thanks for your patches. In principle I like them, buy my
> GCC 4.3
> doesn't seem to (see below)... which shows that these
> things are
> immensely compiler-dependent and that it's going to be
> difficult to
> find a good solution for everyone.
Well, you're definitely right about that. I'm currently upgrading my Linux machine to GCC 4.3 so I can test on both platforms in the future.
> So I make this counter-proposal to you: how about simply
> turning off
> the MSVC warning with a #pragma ?
That was actually my first thought, but I couldn't figure out where to put the pragma to make it work transparently. If someone else with MSVC could try to figure it out that would be nice (make sure you're at warning level 4). Code like this obviously needs to go somewhere in Eigen:
#ifdef (defined _MSC_VER)
#pragma warning( push )
#pragma warning( disable: 4127 )
// code causing warning goes here
#ifdef (defined _MSC_VER)
#pragma warning( pop )
> With your 1st patch, the compilation of this program....
> succeeds (no
> compiler output at all)! So i get a binary that of course
> failed on an
> assertion at runtime.
That's probably similar to the issue where I got compilation errors in the tests that GCC didn't due to it ignoring code inside an always false conditional. It's likely that if I had enabled all MSVC optimizations, I would have gotten the same result. Perhaps this solution can be massaged a bit to work...
> With your 2nd patch, the compiler output is:
Ya, that definitely is a mouthful. All MSVC spits out is:
=== BEGIN MSVC OUTPUT =================================
c:\subversion\eigen2\eigen\src/Core/CwiseBinaryOp.h(105) : error C2027: use of undefined type 'Eigen::ei_static_assert<condition,message>'
c:\subversion\eigen2\eigen\src/Core/CwiseBinaryOp.h(92) : while compiling class template member function 'Eigen::CwiseBinaryOp<BinaryOp,Lhs,Rhs>::CwiseBinaryOp(const Lhs &,const Rhs &,const BinaryOp &)'
..\..\test\adjoint.cpp(121) : see reference to class template instantiation 'Eigen::CwiseBinaryOp<BinaryOp,Lhs,Rhs>' being compiled
=== END MSVC OUTPUT ===================================
My second suggestion is somewhat based off of how Boost and Loki implement static assertions, but they have #ifdefs for various compilers to allow for a little fine-tuning. I think that may be overkill for Eigen since I don't believe Eigen's static assertions are meant to be generically usable by Eigen users (the enum wouldn't be acceptable if it was). So I'm going to try to tweak my first solution a bit, and if someone could find a place where that above pragma code can go that actually works, that would also solve the problem.