Hi Steve, I always saw this as a harmless warning, safe to ignore, since both caller and callee are forced back to the same convention so it all works out in the end. Or can you envision a scenario where this would be harmfull?
Thank god Microsoft abandoned this calling convention circus with 64bit. Cheers, Thomas On Tue, Jun 18, 2019 at 1:31 PM Steve Groeger <groe...@uk.ibm.com> wrote: > Hi all, > > I had a query regarding the use of JNICALL with varargs functions, which I > am hoping someone can comment on. > > As explained on MSDN at [1], all functions declared as __stdcall that have > variable parameters (varargs) will be forced back to __cdecl by the MSVC. > In such case, keeping JNICALL for varargs functions/function pointers > turns out be inappropriate. > e.g. > > include/jni.h > jobject (JNICALL *NewObject) > (JNIEnv *env, jclass clazz, jmethodID methodID, ...); > > According to [2], stdcall does not support variadic calls in C on 32-bit > x86 targets. > > When compiling a JNI native (calling NewObject) with Clang, it ends up > with the warning as follows: > ...\include\jni.h:277:14: warning: stdcall calling convention ignored on > variadic function [-Wignored-attributes] > jobject (JNICALL *NewObject) > ^ > > So basically the compiler is saying it can't do what was requested, as > such should we stop asking for JNICALL on varargs functions. > Doing so will only improve the portability of code to a wider set of > compilers. > > Comments? > > [1] https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx > [2] https://clang.llvm.org/docs/AttributeReference.html#stdcall > > Thanks > Steve Groeger > IBM Runtime Technologies > Hursley, Winchester > Tel: (44) 1962 816911 Mobex: 279990 Mobile: 07718 517 129 > Fax (44) 1962 816800 > Lotus Notes: Steve Groeger/UK/IBM > Internet: groe...@uk.ibm.com > > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > >