Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-01

Converting header with va_list

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I need to convert this:

android]$ gedit
~/Programas/android-ndk-r5/platforms/android-8/arch-arm/usr/include/jni.h

void        (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list);

To Pascal. I tryed using array of const, but it keeps crashing in this call =(

CallStaticVoidMethodV:procedure(Env:PJNIEnv;AClass:JClass;MethodID:JMethodID;Args:array of const);{$ifdef mswindows}stdcall;{$else}cdecl;{$endif}

Any ideas if using array of const is a good idea or if something else is better? My target is Android (via arm-linux in FPC)

thanks,

Felipe Monteiro de Carvalho
Jeppe Græsdal Johansen
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 18 lines
Hello, I need to convert this: android]$ gedit ~/Programas/android-ndk-r5/platforms/android-8/arch-arm/usr/include/jni.h void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); To Pascal. I tryed using array of const, but it keeps crashing in this call =( CallStaticVoidMethodV:procedure(Env:PJNIEnv;AClass:JClass;MethodID:JMethodID;Args:array of const);{$ifdef mswindows}stdcall;{$else}cdecl;{$endif} Any ideas if using array of const is a good idea or if something else is better? My target is Android (via arm-linux in FPC) thanks,

Does this work?
CallStaticVoicMethodV:
procedure(Env:PJNIEnv;AClass:JClass;MethodID:JMethodID); {$ifdef mswindows}stdcall;{$else}cdecl;{$endif} varargs;

I recon that it is almost the same, according to the FPC documentation

Jonas Maebe
to Felipe Monteiro de Carvalho: I need to convert this: android]$ gedit ~/Programas/android-ndk-r5/platforms/android-8/arc…
Felipe Monteiro de Carvalho wrote 11 lines
I need to convert this: android]$ gedit ~/Programas/android-ndk-r5/platforms/android-8/arch-arm/usr/include/ jni.h void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list); To Pascal. I tryed using array of const, but it keeps crashing in this call =(

"array of const" or "varargs" only matches "..." in C. va_list is an ABI-defined, and often at least partially handled via compiler magic, record type. Look for the copy of varargs.h for the gcc version you use on Android.

Jonas

Felipe Monteiro de Carvalho
to Jonas Maebe

Hello,

Thanks, it is good to have some input as to what would be necessary, but in the mean time I solved my problem in another way. JNI has another way of sending the parameters, the A functions:

CallStaticVoidMethodA:procedure(Env:PJNIEnv;AClass:JClass;MethodID:JMethodID;Args:PJValue);

And this worked for me sending a pointer to the first element of a pascal static Array in the parameter Args.

Felipe Monteiro de Carvalho