<分区>
这是我的bmi.c
#include<stdio.h>
float height;
float weight;
int getbmi(float h , float w);
int main(){
return 0;
}
int getbmi(float h , float w)
{
//float h , w;
float res;
res = w/h;
res = res/h;
return res;
}
我正在这样编译:
gcc -shared -Wl,-soname,adder -o bmi.so -fPIC bmi.c
那么这是我的getbmi.py
from ctypes import *
bmi = CDLL('./bmi.so')
h = c_float(1.6002)
w = c_float(75)
getbmi = bmi.getbmi
getbmi.restype = c_float
print(getbmi(h, w))
当我运行 getbmi.py 时,我只得到一个输出:nan
我很困惑