JNI调用C++函数, 该函数编译错误, 求解!
=============================
DataCardDll.CPP代码如下
=============================
#include "CallDll.h"
#include "stdio.h"
#include "windows.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*Type_SetPara)(int, int, int*, int,
unsigned short, unsigned short, int, int,
int);
typedef int (*Type_DataIn)(float *, float *, unsigned char *,
int, int);
JNIEXPORT jint JNICALL Java_CallDll_callInfoCollect
(JNIEnv *env, jobject _obj, jint _sampleRate, jint _adChannelNo, jintArray _adpgaChannels,
jint _dioModal, jchar _pwm1, jchar _pwm2, jint _comparatorEnable, jint _extTriggor,
jfloatArray _voltageIn1, jfloatArray _voltageIn2, jbooleanArray _d1,
jint _sampleNo, jint _deviceNo)
{
HINSTANCE hDll = LoadLibrary("RealDataCardDll.dll");
if(NULL == hDll)
{
printf("Cann't find real Dll");
}
Type_SetPara MPS_SetPara = (Type_SetPara)GetProcAddress(hDll, "SetPara");
if(NULL == MPS_SetPara)
{
printf("Cann't find <SetPara> function");
}
Type_DataIn MPS_DataIn = (Type_DataIn)GetProcAddress(hDll, "DataIn");
if(NULL == MPS_DataIn)
{
printf("Cann't find <DataIn> function");
}
int SampleRate = _sampleRate;
int ADChannelNo = _adChannelNo;
int* ADPGAChannels = env->GetIntArrayElements(_adpgaChannels, NULL);
int DIOModal = _dioModal;
unsigned short PWM1 = _pwm1;
unsigned short PWM2 = _pwm2;
int ComparatorEnable = _comparatorEnable;
int ExtTriggor = _extTriggor;
float* VoltageIn1 = env->GetFloatArrayElements(_voltageIn1, NULL);
float* VoltageIn2 = env->GetFloatArrayElements(_voltageIn2, NULL);
unsigned char* D1 = env->GetBooleanArrayElements(_d1, NULL);
int SampleNo = _sampleNo;
int DeviceNo = _deviceNo;
int result = 0;
int failAmount = 0;
result = MPS_SetPara(SampleRate, ADChannelNo, ADPGAChannels, DIOModal, PWM1, PWM2,
ComparatorEnable, ExtTriggor, DeviceNo);
....
}
=============================
CallDll.h 代码如下
=============================
#include <jni.h>
#ifndef _Included_CallDll
#define _Included_CallDll
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_CallDll_callInfoCollect
(JNIEnv *, jobject, jint, jint, jintArray, jint, jchar, jchar, jint, jint, jfloatArray, jfloatArray, jbooleanArray, jint, jint);
#ifdef __cplusplus
}
#endif
#endif
=============================
按在VC++ 6.0 下按F7进行编译出错, 该句出错:
int* ADPGAChannels = env->GetIntArrayElements(_adpgaChannels, NULL);
编译窗口显示如下错误:
-------------------Configuration: DataCardDll - Win32 Debug--------------------