Currently if -Wdouble-promotion is enabled, then invoking methods that take float parameters will trigger the warning. For example:
jni::Method<Tag, jni::jfloat> method = klass.GetMethod<void, jni::float>(...);
object.Call(env, method, 0.0f);
The warning looks something like:
.../jni.hpp/include/jni/functions.hpp:202:73: error: implicit conversion increases floating-point precision: 'float' to 'double' [-Werror,-Wdouble-promotion]
Wrap<jobject*>(env.NewObject(Unwrap(clazz), Unwrap(method), Unwrap(std::forward<Args>(args))...)));
~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../jni.hpp/include/jni/class.hpp:50:41: note: in instantiation of function template specialization 'jni::NewObject<signed char, signed char, short, short, int, int, long long, long long, float, double, unsigned char, jni::jstring *>' requested here
return Object<TagType>(&NewObject(env, *clazz, method, Untag(args)...));
This is because float is automatically promoted to double in varargs.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48379 notes that this is a pretty useless case for this warning, but still, we could suppress it by introducing a templated Vararg function that does an explicit static cast in the case of float.
Currently if
-Wdouble-promotionis enabled, then invoking methods that takefloatparameters will trigger the warning. For example:The warning looks something like:
This is because
floatis automatically promoted todoublein varargs.https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48379 notes that this is a pretty useless case for this warning, but still, we could suppress it by introducing a templated
Varargfunction that does an explicit static cast in the case offloat.