2013-04-12 46 views
0

我想構建一個非常簡單的本地函數使用ndk生成並獲得以下錯誤。Android NDK構建失敗的簡單本機功能

DriverAdapter.cpp:6:69: error: expected ',' or '...' before 'this' 

以下是我.mk和.cpp文件

DriverAdapter.cpp

#include <jni.h> 
#include <string.h> 
#include <android/log.h> 
#define DEBUG_TAG "NDK_AndroidNDK1SampleActivity" 

void Java_com_ihearhtpi_MainActivity_helloLog(JNIEnv * env, jobject this, jstring logThis) 
{ 
    jboolean isCopy; 
    const char * szLogThis = (*env)->GetStringUTFChars(env, logThis, &isCopy); 
    __android_log_print(ANDROID_LOG_DEBUG, DEBUG_TAG, "NDK:LC: [%s]", szLogThis); 
    (*env)->ReleaseStringUTFChars(env, logThis, szLogThis); 
} 

Android.mk

LOCAL_PATH:= $(叫我-DIR)

include $(call all-subdir-makefiles) 
include $(CLEAR_VARS) 
LOCAL_LDLIBS := -llog 
LOCAL_MODULE :=driver 
LOCAL_SRC_FILES :=DriverAdapter.cpp 
include $(BUILD_SHARED_LIBRARY) 

不知道爲什麼這個 正在發生。

回答

1

的問題是,this是C++的關鍵字。而且你不能使用關鍵字作爲變量名稱。

+0

噢耶...謝謝。 – moesef

+1

以下替代品是常用的:thiz,self,me,_pThis ...選擇一個:) –

1

你不能說出你的觀點「這個」