为什么我在构建python模块时遇到这个错误?

2024-09-28 20:48:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在用C语言构建一个python模块,我已经跟随了一系列教程来了解我自己的构建点,并且我已经很好地掌握了正在发生的事情。在

但是,当我运行脚本来设置所有内容时,我有以下打印输出。看起来这个错误来自python-dev中的一个头文件;但是,我想在这里确认这不是我正在做的事情。我将包括错误代码,我可以提供其他文件的要求。在

sudo python setup.py build
running build
running build_ext
building 'lidar' extension
arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/include -I/usr/include/python2.7 -c lidar_module.c -o build/temp.linux-armv6l-2.7/lidar_module.o
lidar_module.c: In function ‘lidar_test’:
lidar_module.c:8:6: warning: unused variable ‘sts’ [-Wunused-variable]
  int sts = 0;
      ^
In file included from /usr/include/python2.7/Python.h:58:0,
                 from lidar_module.c:1:
lidar_module.c: At top level:
/usr/include/python2.7/pyport.h:802:39: error: expected ‘,’ or ‘;’ before ‘void’
 #               define PyMODINIT_FUNC void
                                       ^
lidar_module.c:24:1: note: in expansion of macro ‘PyMODINIT_FUNC’
 PyMODINIT_FUNC initlidar(){
 ^
lidar_module.c:3:18: warning: ‘lidarError’ defined but not used [-Wunused-variable]
 static PyObject *lidarError;
                  ^
lidar_module.c:19:20: warning: ‘lidar_methods’ defined but not used [-Wunused-variable]
 static PyMethodDef lidar_methods[] = {
                    ^
error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1

我偷看了一下头文件,在错误区域附近找到了这个。在

^{pr2}$

Tags: 文件buildincludelinuxusr错误事情variable