From: SourceForge.net <no...@so...> - 2010-03-09 03:05:34
|
Bugs item #2965875, was opened at 2010-03-08 22:04 Message generated for change (Comment added) made by ebf You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2965875&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: java Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Eric Friedman (ebf) Assigned to: William Fulton (wsfulton) Summary: int64_t defined incorrectly Initial Comment: Hi, I am using SWIG 1.3.39 and GCC 4.4.1 (Ubuntu 4.4.1-4ubuntu9) on Ubuntu 9.10 (Linux efriedma-ux 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 02:39:34 UTC 2010 x86_64 GNU/Linux). Normally on 64-bit Linux, int64_t is defined to be a `long int`. However, in SWIG (at least for Java), it is defined incorrectly, as seen in the following simple interface file: // foo.i %module foo %{ #include <boost/static_assert.hpp> #include <boost/type_traits/is_same.hpp> BOOST_STATIC_ASSERT(( boost::is_same<int64_t, jlong>::value )); %} This may be compiled as follows: $ swig -c++ -java foo.i $ g++ foo_wrap.cxx foo_wrap.cxx:216: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' The error means the Boost static assertion has failed, which indicates that `int64_t` and `jlong` are not the same type. (The result is the same even if I include the SWIG import <stdint.i>.) However, the following C++ program, which has the same check compiles without a problem: #include <boost/static_assert.hpp> #include <boost/type_traits/is_same.hpp> int main() { BOOST_STATIC_ASSERT(( boost::is_same<int64_t, jlong>::value )); return 0; } Trying to track this down, it seems as though the problem is due to the following lines in the SWIG-generated source file (foo_wrap.cxx): /* Fix for jlong on 64-bit x86 Solaris */ #if defined(__x86_64) # ifdef _LP64 # undef _LP64 # endif #endif Doing this causes the JNI headers to make the `jlong` type as a typedef for `long long int`. I don't understand why this is being done, as it's different from `int64_t`. Thanks, Eric P.S. Looking at the Subversion history for this change, I came across the following: http://swig.svn.sourceforge.net/viewvc/swig?view=rev&revision=6891 The commit message (from marcelomatus) is "fix warning(error?) with jlong + x86_64". Does that give any clue as to why this introduced? Are there other problems with SWIG on 64-bit platforms? (The uncertainty in the commit message is a bit unnerving.) ---------------------------------------------------------------------- >Comment By: Eric Friedman (ebf) Date: 2010-03-08 22:05 Message: Also forgot to mention: I also checked with the latest version of SWIG (1.3.40), and it seems that this issue is still present there as well. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2965875&group_id=1645 |