Compile issue on Linux x86_64

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Compile issue on Linux x86_64

Thomas Nelson-10
I just bumped myself up to 0.9 and updated my build scripts.

Item the first:
Good job.  I actually get warm fuzzies when a code base gets smaller; it
means that people are putting thought and effort into keeping it clean and
clean code is usually good code.  Makes me know that I made the right
decision when I chose it.

Item the second:
I'm getting no problems with the MSVC build (32bit) but on Linux (Fedora12
x86_64, gcc 4.4.3-4) I'm getting a build error (exact error after note) but
it looks like a conversion between void * and int.

Anyone else see/solve this yet?  I'm investigating now.

Error:

Building CXX object external/luabind/CMakeFiles/luabind.dir/src/class.cpp.o
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.4.3/../../../../include/c++/4.4.3/utility
:64,
                 from /usr/local/include/boost/foreach.hpp:28,
                 from
/home/tomn/work/eidolon/external/luabind/src/class.cpp:26:
/usr/lib/gcc/x86_64-redhat-linux/4.4.3/../../../../include/c++/4.4.3/bits/st
l_pair.h: In constructor 'std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with _U1
= int, _U2 = int, _T1 = void*, _T2 = int]':
/home/tomn/work/eidolon/external/luabind/./luabind/detail/object_rep.hpp:58:
instantiated from here
/usr/lib/gcc/x86_64-redhat-linux/4.4.3/../../../../include/c++/4.4.3/bits/st
l_pair.h:90: error: invalid conversion from 'int' to 'void*'
make[2]: *** [external/luabind/CMakeFiles/luabind.dir/src/class.cpp.o] Error
1
make[1]: *** [external/luabind/CMakeFiles/luabind.dir/all] Error 2
make: *** [all] Error 2

TomN

--
Thomas Nelson  [hidden email]  
--------------------------------------------------------------
"If you still have gas, you're not lost".
- French explorer Pierre Frontage.
(M.Frontage was so influential in the exploration of North America many
roads are still named after him.)



------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Compile issue on Linux x86_64

Daniel Wallin
On Tue, Feb 16, 2010 at 09:59:20AM -0800, Thomas Nelson wrote:
> I just bumped myself up to 0.9 and updated my build scripts.
>
> Item the first:
> Good job.  I actually get warm fuzzies when a code base gets smaller; it
> means that people are putting thought and effort into keeping it clean and
> clean code is usually good code.  Makes me know that I made the right
> decision when I chose it.

Thank you.

> Item the second:
> I'm getting no problems with the MSVC build (32bit) but on Linux (Fedora12
> x86_64, gcc 4.4.3-4) I'm getting a build error (exact error after note) but
> it looks like a conversion between void * and int.
>
> Anyone else see/solve this yet?  I'm investigating now.

I believe this is an open issue on the C++ standard library:

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#811

A workaround would be to explicitly cast the null ptr to void*:

diff --git a/luabind/detail/object_rep.hpp b/luabind/detail/object_rep.hpp
index 243aae5..dafa653 100644
--- a/luabind/detail/object_rep.hpp
+++ b/luabind/detail/object_rep.hpp
@@ -55,7 +55,7 @@ namespace luabind { namespace detail
  std::pair<void*, int> get_instance(class_id target) const
  {
  if (m_instance == 0)
- return std::pair<void*, int>(0, -1);
+ return std::pair<void*, int>((void*)0, -1);
  return m_instance->get(target);
  }

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

SOLVED: Compile issue on Linux x86_64

Thomas Nelson-10
In reply to this post by Thomas Nelson-10
Attached is the diff, you will need to adjust the file paths.

The problem: It seems that 64bit gcc 4.4.3-4 may be a bit pedantic when it
comes to template expansion.  When presented with the following:

std::pair<void*, int>(0, -1)

It decides that the "0" is an integer which could not possibly under any
circumstances be considered a void * to NULL, or at least not in any sane
world that you and I might inhabit. Therefore the programmer is obviously
attempting to initialize a std::pair<void*, int> with a std:pair<int, int>
and this is just not done in polite circles. Throwing up its hands in
disgust at those silly programmers it spits out a helpful message, exits and
goes for a beer.

Solution: Explain politely to gcc that yes, that really is a void pointer to
null and not the integer 0.

std::pair<void*, int>(static_cast<void *>(0), -1)

I was always under the impression that integer 0 would always be considered
a pointer if used in a context like this.

TomN

--
Thomas Nelson  [hidden email]  
--------------------------------------------------------------
Don't anthropomorphize computers, they don't like it.


> -----Original Message-----
> From: Thomas Nelson [mailto:[hidden email]]
> Sent: Tuesday, February 16, 2010 9:59 AM
> To: [hidden email]
> Subject: [luabind] Compile issue on Linux x86_64
>
> I just bumped myself up to 0.9 and updated my build scripts.
>
> Item the first:
> Good job.  I actually get warm fuzzies when a code base gets smaller; it
> means that people are putting thought and effort into keeping it clean and
> clean code is usually good code.  Makes me know that I made the right
> decision when I chose it.
>
> Item the second:
> I'm getting no problems with the MSVC build (32bit) but on Linux (Fedora12
> x86_64, gcc 4.4.3-4) I'm getting a build error (exact error after note)
> but
> it looks like a conversion between void * and int.
>
> Anyone else see/solve this yet?  I'm investigating now.
>
> Error:
>
> Building CXX object
> external/luabind/CMakeFiles/luabind.dir/src/class.cpp.o
> In file included from
> /usr/lib/gcc/x86_64-redhat-
> linux/4.4.3/../../../../include/c++/4.4.3/utility
> :64,
>                  from /usr/local/include/boost/foreach.hpp:28,
>                  from
> /home/tomn/work/eidolon/external/luabind/src/class.cpp:26:
> /usr/lib/gcc/x86_64-redhat-
> linux/4.4.3/../../../../include/c++/4.4.3/bits/st
> l_pair.h: In constructor 'std::pair<_T1, _T2>::pair(_U1&&, _U2&&) [with
> _U1
> = int, _U2 = int, _T1 = void*, _T2 = int]':
> /home/tomn/work/eidolon/external/luabind/./luabind/detail/object_rep.hpp:5
> 8:
> instantiated from here
> /usr/lib/gcc/x86_64-redhat-
> linux/4.4.3/../../../../include/c++/4.4.3/bits/st
> l_pair.h:90: error: invalid conversion from 'int' to 'void*'
> make[2]: *** [external/luabind/CMakeFiles/luabind.dir/src/class.cpp.o]
> Error
> 1
> make[1]: *** [external/luabind/CMakeFiles/luabind.dir/all] Error 2
> make: *** [all] Error 2
>
> TomN
>
> --
> Thomas Nelson  [hidden email]
> --------------------------------------------------------------
> "If you still have gas, you're not lost".
> - French explorer Pierre Frontage.
> (M.Frontage was so influential in the exploration of North America many
> roads are still named after him.)
>
>
>
> --------------------------------------------------------------------------
> ----
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user

luabindudiff.txt (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Compile issue on Linux x86_64

Thomas Nelson-10
In reply to this post by Daniel Wallin

Thanks for the link, I didn't realize it was an issue at that scope.  That's
unpleasant, but good to know.


> -----Original Message-----
> From: Daniel Wallin [mailto:[hidden email]]
>
> I believe this is an open issue on the C++ standard library:
>
>   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#811
>



------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Compile issue on Linux x86_64

Łukasz Wołowiec
In reply to this post by Daniel Wallin
> I believe this is an open issue on the C++ standard library:
>
>  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#811
>
> A workaround would be to explicitly cast the null ptr to void*:

I encountered this problem when compiling luabind on VC 2010 as well. As far, as I know, this is not 'open' issue in the new C++0x standard anymore. It was solved by using the new 'nullptr' keyword.

So, instead of:
        return std::pair<void*, int>((void*)0, -1);

you can express it the more 'legal' way:
        return std::pair<void*, int>(nullptr, -1);

I tried it with VC2010 and worked fine.

--
Lukasz

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Compile issue on Linux x86_64

Daniel Wallin
On Wed, Feb 17, 2010 at 09:42:22AM +0100, Łukasz Wołowiec wrote:
> > I believe this is an open issue on the C++ standard library:
> >
> >  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#811
> >
> > A workaround would be to explicitly cast the null ptr to void*:
>
> I encountered this problem when compiling luabind on VC 2010 as well.
> As far, as I know, this is not 'open' issue in the new C++0x standard
> anymore. It was solved by using the new 'nullptr' keyword.

It is open, since it breaks existing code. See the link I posted.

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: SOLVED: Compile issue on Linux x86_64

Daniel Wallin
In reply to this post by Thomas Nelson-10
On Tue, Feb 16, 2010 at 01:54:58PM -0800, Thomas Nelson wrote:

> Attached is the diff, you will need to adjust the file paths.
>
> The problem: It seems that 64bit gcc 4.4.3-4 may be a bit pedantic when it
> comes to template expansion.  When presented with the following:
>
> std::pair<void*, int>(0, -1)
>
> It decides that the "0" is an integer which could not possibly under any
> circumstances be considered a void * to NULL, or at least not in any sane
> world that you and I might inhabit. Therefore the programmer is obviously
> attempting to initialize a std::pair<void*, int> with a std:pair<int, int>
> and this is just not done in polite circles. Throwing up its hands in
> disgust at those silly programmers it spits out a helpful message, exits and
> goes for a beer.
>
> Solution: Explain politely to gcc that yes, that really is a void pointer to
> null and not the integer 0.
>
> std::pair<void*, int>(static_cast<void *>(0), -1)
>
> I was always under the impression that integer 0 would always be considered
> a pointer if used in a context like this.

Thank you! Applied to the 0.9 branch, except I changed
static_cast<void*>(p) to (void*)p.

--
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user