SOLVED: Compile issue on Linux x86_64

"Thomas Nelson" <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <9F661A3D4B6B46709612445C82C1930E@Spawn>
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  [email protected]  
--------------------------------------------------------------
Don't anthropomorphize computers, they don't like it.


> -----Original Message-----
> From: Thomas Nelson [mailto:[email protected]]
> Sent: Tuesday, February 16, 2010 9:59 AM
> To: [email protected]
> 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  [email protected]
> --------------------------------------------------------------
> "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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
luabindudiff.txt (text/plain, 2.8 KB)
Index: E:/development/eidolon/external/luabind/src/class_rep.cpp
===================================================================
--- E:/development/eidolon/external/luabind/src/class_rep.cpp	(revision 448)
+++ E:/development/eidolon/external/luabind/src/class_rep.cpp	(revision 449)
@@ -123,7 +123,7 @@
 {
 	const int size = sizeof(object_rep);
 	char* mem = static_cast<char*>(lua_newuserdata(L, size));
-	return std::pair<void*,void*>(mem, 0);
+	return std::pair<void*,void*>(mem, static_cast<void *>(0));
 }
 
 namespace
Index: E:/development/eidolon/external/luabind/src/inheritance.cpp
===================================================================
--- E:/development/eidolon/external/luabind/src/inheritance.cpp	(revision 448)
+++ E:/development/eidolon/external/luabind/src/inheritance.cpp	(revision 449)
@@ -144,7 +144,7 @@
         return std::make_pair(p, 0);
 
     if (src >= m_vertices.size() || target >= m_vertices.size())
-        return std::pair<void*, int>(0, -1);
+        return std::pair<void*, int>(static_cast<void *>(0), -1);
 
     std::ptrdiff_t const object_offset =
         (char const*)dynamic_ptr - (char const*)p;
@@ -154,7 +154,7 @@
     if (cached.first != cache::unknown)
     {
         if (cached.first == cache::invalid)
-            return std::pair<void*, int>(0, -1);
+            return std::pair<void*, int>(static_cast<void *>(0), -1);
         return std::make_pair((char*)p + cached.first, cached.second);
     }
 
@@ -192,7 +192,7 @@
 
     m_cache.put(src, target, dynamic_id, object_offset, cache::invalid, -1);
 
-    return std::pair<void*, int>(0, -1);
+    return std::pair<void*, int>(static_cast<void *>(0), -1);
 }
 
 void cast_graph::impl::insert(
Index: E:/development/eidolon/external/luabind/luabind/detail/object_rep.hpp
===================================================================
--- E:/development/eidolon/external/luabind/luabind/detail/object_rep.hpp	(revision 448)
+++ E:/development/eidolon/external/luabind/luabind/detail/object_rep.hpp	(revision 449)
@@ -55,7 +55,7 @@
 		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>(static_cast<void *>(0), -1);
 			return m_instance->get(target);
 		}
 
Index: E:/development/eidolon/external/luabind/luabind/detail/instance_holder.hpp
===================================================================
--- E:/development/eidolon/external/luabind/luabind/detail/instance_holder.hpp	(revision 448)
+++ E:/development/eidolon/external/luabind/luabind/detail/instance_holder.hpp	(revision 449)
@@ -98,7 +98,7 @@
             weak ? weak : get_pointer(p)));
 
         if (!naked_ptr)
-            return std::pair<void*, int>(0, 0);
+            return std::pair<void*, int>(static_cast<void *>(0), 0);
 
         return get_class()->casts().cast(
             naked_ptr
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.