Bullet 2.82 and btInfinityMask compiler warning

Ingar
Posts: 3
Joined: Sun Nov 10, 2013 11:18 am
Location: Belgium

Bullet 2.82 and btInfinityMask compiler warning

Post by Ingar »

I'm in the habit of compiling my C++ project with -Wall -Werror to catch potential problems
as early as possible. Unfortunatly bullet 2.82 generates a warning, forcing me to disable -Werror.

The error message, gcc version is 4.8.2 (Arch Linux):

Code: Select all

/usr/include/bullet/LinearMath/btScalar.h:337:14: warning: 'btInfinityMask' defined but not used [-Wunused-variable]
  static  int btInfinityMask = 0x7F800000;
              ^
It is only a warning, but it is annoying, as it clutters my build log. A workaround to make the message go away would be greatly appreciated.
c6burns
Posts: 149
Joined: Fri May 24, 2013 6:08 am

Re: Bullet 2.82 and btInfinityMask compiler warning

Post by c6burns »

Ingar
Posts: 3
Joined: Sun Nov 10, 2013 11:18 am
Location: Belgium

Re: Bullet 2.82 and btInfinityMask compiler warning

Post by Ingar »

Solved it for now by adding an extra definition to my own header files.

Code: Select all

#if (BT_BULLET_VERSION == 282)
inline int bullet_btInfinityMask()
{
	return btInfinityMask;
}
#endif
In the end, this is just as bad as special #pragma directives or preprocessor flags,
but at least it only suppresses this particular warning.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet 2.82 and btInfinityMask compiler warning

Post by Erwin Coumans »

That flag is only used for some SSE/SIMD code, and we don't enable that for your compiler/platform combination, hence it is unused.

We could add that line in btScalar.h (without the version check), would that help you?

inline int bullet_btInfinityMask()
{
return btInfinityMask;
}
Ingar
Posts: 3
Joined: Sun Nov 10, 2013 11:18 am
Location: Belgium

Re: Bullet 2.82 and btInfinityMask compiler warning

Post by Ingar »

It does solve the issue for me. Note that I didn't actually change the bullet header, but my own header that #includes btScalar.h.
Maybe it's possible to #ifdef the btInfinityMask definition such that it dissapears if the SIMD implementation isn't being used.
marzoul
Posts: 1
Joined: Fri Jul 18, 2014 4:30 pm

Re: Bullet 2.82 and btInfinityMask compiler warning

Post by marzoul »

Erwin Coumans wrote:We could add that line in btScalar.h (without the version check), would that help you?

inline int bullet_btInfinityMask()
{
return btInfinityMask;
}
Depending on optimization levels and debug parameters (-g), inline functions may not be kept and compiled, so the warning could remain. Plus it's a definition of an unuseful function, and it lets btInfinityMask instantiated as a variable in each source file the header is included, just because of a cast.

I see two other solutions, IMHO a bit cleaner.

Fist the variable could be declared with the attribute "unused" (GCC and Clang handle this):

Code: Select all

__attribute((__unused__)) static  int btInfinityMask = 0x7F800000;
Or, don't try to define BT_INFINITY, instead define btInfinityMask as macro and the following function:

Code: Select all

#define btInfinityMask 0x7F800000
static inline int btIsInfinity(float f) {
    return (*(int*)&f) == btInfinityMask;
}