我需要添加可以编译的ac项目,gcc如下所示
gcc -I/usr/include/epic5.1 -I/usr/include/i386-linux-gnu/epic5.1 -I./smproject/ -o code code.c ./smproject/smlib.so -lepic5.1
Run Code Online (Sandbox Code Playgroud)
我已将code.c文件内容移动到我的Android NDK .cpp文件(src/main/cpp/native-lib.cpp),并将smproject目录中的所有文件移动到src/main/cpp/smproject/目录
这是我的CMakeList.txt内容
# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html
# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)
# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple …Run Code Online (Sandbox Code Playgroud) Cython 相当于 c 定义
#define myfunc(Node x,...) SetNode(x.getattributeNode(),__VA_ARGS__)
Run Code Online (Sandbox Code Playgroud)
我有 ac api SetNode 它接受第一个参数结构类型节点的节点和 N 个变量(N 是 0-N 的变量号)
这是解决此类问题的 ac 示例
示例API.c
#include<stdarg.h>
float sumN(int len,...){
va_list argp;
int i;
float s=0;
va_start(argp,len);
for(i=0;i<len;i++){
s+=va_arg(argp,int);
}
va_end(argp);
}
Run Code Online (Sandbox Code Playgroud)
示例API.h
#include<stdarg.h>
float sumN(int len,...)
Run Code Online (Sandbox Code Playgroud)
示例代码.c
#include<stdarg.h>
#include"exampleAPI.h"
int len(float first,...){
va_list argp;
int i=1;
va_start(argp,first);
while(1){
if(va_arg(argp,float)==NULL){
return i
}
else{
i++;
}
}
va_end(argp);
}
#define sum(...) sumN(len(__VA_ARGS__),__VA_ARGS__)
Run Code Online (Sandbox Code Playgroud)
现在打电话
sum(1,2,3,4);
Run Code Online (Sandbox Code Playgroud)
将返回10.000000
sum(1.5,6.5);
Run Code Online (Sandbox Code Playgroud)
将返回8.00000
我需要一个用于波纹管 c 定义的 cython 替代方案,而不是上面的示例,因为我有一个 …