gpt4 book ai didi

Android NDK Build 因简单的 native 功能而失败

转载 作者:行者123 更新时间:2023-11-28 03:19:08 25 4
gpt4 key购买 nike

我正在尝试使用 ndk-build 构建一个非常简单的 native 函数并收到以下错误。

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

下面是我的.mk和.cpp文件

驱动适配器.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);
}

安卓.mk

LOCAL_PATH := $(调用我的目录)

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

不知道为什么会这样。

最佳答案

问题是 this 是 c++ 关键字。并且您不能使用关键字作为变量名。

关于Android NDK Build 因简单的 native 功能而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15980626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com