New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid cast when building with MinGW-w64 #394

Open
markand opened this Issue May 27, 2015 · 8 comments

Comments

Projects
None yet
3 participants
@markand

markand commented May 27, 2015

I'm trying to build bullet 2.83.4 on Windows using MinGW-w64 with GCC 4.9.

I get the following error while building:

[ 67%] Building CXX object examples/ExampleBrowser/CMakeFiles/App_ExampleBrowser.dir/__/__/Extras/Serialize/BulletFileLoader/bFile.obj
C:\src\64\bullet3-2.83.4\Extras\Serialize\BulletFileLoader\bFile.cpp: In member function 'void bParse::bFile::swapDNA(char*)':
C:\src\64\bullet3-2.83.4\Extras\Serialize\BulletFileLoader\bFile.cpp:446:13: error: cast from 'char*' to 'long int' loses precision [-fpermissive]
   nr= (long)cp;
             ^
C:\src\64\bullet3-2.83.4\Extras\Serialize\BulletFileLoader\bFile.cpp:483:13: error: cast from 'char*' to 'long int' loses precision [-fpermissive]
   nr= (long)cp;

Small precision, this happens only in 64 bit (MinGW-w64). 32 bits MinGW compiles fine.

@johnfredcee

This comment has been minimized.

Show comment
Hide comment
@johnfredcee

johnfredcee Feb 3, 2016

long is not big enough to hold a pointer : one possible fix is to change these to long long ; there are only a few sites where it is a problem.

johnfredcee commented Feb 3, 2016

long is not big enough to hold a pointer : one possible fix is to change these to long long ; there are only a few sites where it is a problem.

@johnfredcee

This comment has been minimized.

Show comment
Hide comment
@johnfredcee

johnfredcee commented Feb 3, 2016

@markand

This comment has been minimized.

Show comment
Hide comment
@markand

markand Feb 4, 2016

What about using (u)intrptr_t which is designed for?

markand commented Feb 4, 2016

What about using (u)intrptr_t which is designed for?

@johnfredcee

This comment has been minimized.

Show comment
Hide comment
@johnfredcee

johnfredcee Feb 4, 2016

No idea. Is C++11 specific code ok? The code base looks old and hairy, so I went for an old and hairy solution!

johnfredcee commented Feb 4, 2016

No idea. Is C++11 specific code ok? The code base looks old and hairy, so I went for an old and hairy solution!

@erwincoumans

This comment has been minimized.

Show comment
Hide comment
@erwincoumans

erwincoumans Feb 4, 2016

Member

Sure, I'll look into it.

intptr_t has some portability issues but it only requires C99 not C++11, see also http://stackoverflow.com/questions/9492798/using-intptr-t-instead-of-void

The Bullet code base values portability and support for older compilers and platforms, so C++11 and C++14 is not allowed just yet. I rather have the code base look old and hairy rather than getting compile errors on various platforms.

Member

erwincoumans commented Feb 4, 2016

Sure, I'll look into it.

intptr_t has some portability issues but it only requires C99 not C++11, see also http://stackoverflow.com/questions/9492798/using-intptr-t-instead-of-void

The Bullet code base values portability and support for older compilers and platforms, so C++11 and C++14 is not allowed just yet. I rather have the code base look old and hairy rather than getting compile errors on various platforms.

@johnfredcee

This comment has been minimized.

Show comment
Hide comment
@johnfredcee

johnfredcee Feb 4, 2016

That's C 99, not C++ - those were .cpp files I modified..

On 4 February 2016 at 21:38, erwincoumans notifications@github.com wrote:

Sure, I'll look into it.

intptr_t has some portability issues but it only requires C99 not C++11,
see also
http://stackoverflow.com/questions/9492798/using-intptr-t-instead-of-void

The Bullet code base values portability and support for older compilers
and platforms, so C++11 and C++14 is not allowed just yet. I rather have
the code base look old and hairy rather than getting compile errors on
various platforms.


Reply to this email directly or view it on GitHub
#394 (comment)
.


johnfredcee@googlemail.com

johnfredcee commented Feb 4, 2016

That's C 99, not C++ - those were .cpp files I modified..

On 4 February 2016 at 21:38, erwincoumans notifications@github.com wrote:

Sure, I'll look into it.

intptr_t has some portability issues but it only requires C99 not C++11,
see also
http://stackoverflow.com/questions/9492798/using-intptr-t-instead-of-void

The Bullet code base values portability and support for older compilers
and platforms, so C++11 and C++14 is not allowed just yet. I rather have
the code base look old and hairy rather than getting compile errors on
various platforms.


Reply to this email directly or view it on GitHub
#394 (comment)
.


johnfredcee@googlemail.com

@erwincoumans

This comment has been minimized.

Show comment
Hide comment
@erwincoumans

erwincoumans Feb 4, 2016

Member

That's what I told indeed, C99. Some C++2003 implementations support the intptr_t C99 feature, others don't. You don't need to have C++11 for that. Even in C++11 the intptr_t is optional, hence non-portable.

Member

erwincoumans commented Feb 4, 2016

That's what I told indeed, C99. Some C++2003 implementations support the intptr_t C99 feature, others don't. You don't need to have C++11 for that. Even in C++11 the intptr_t is optional, hence non-portable.

@markand

This comment has been minimized.

Show comment
Hide comment
@markand

markand Feb 5, 2016

The Bullet code base values portability and support for older
compilers and platforms, so C++11 and C++14 is not allowed just yet. I
rather have the code base look old and hairy rather than getting
compile errors on various platforms.

Deprecated platforms.

Also, a check can be quickly done with CMake to see if a specific
typedef exists :-)

include(CheckTypeSize)
check_type_size(uintptr_t HAVE_UINTPTR_T)

Then you can easily add your own implementation if uintptr_t is missing.

markand commented Feb 5, 2016

The Bullet code base values portability and support for older
compilers and platforms, so C++11 and C++14 is not allowed just yet. I
rather have the code base look old and hairy rather than getting
compile errors on various platforms.

Deprecated platforms.

Also, a check can be quickly done with CMake to see if a specific
typedef exists :-)

include(CheckTypeSize)
check_type_size(uintptr_t HAVE_UINTPTR_T)

Then you can easily add your own implementation if uintptr_t is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment