在 MacOS 上构建 CPython 时函数的隐式声明错误

问题描述

我正在尝试从 MacOS 机器上的 3.9 分支构建 cpython,但在运行 make -j2 -s 时出现以下错误

./Modules/posixmodule.c:7192:9: error: implicit declaration of function 'openpty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    if (openpty(&master_fd,&slave_fd,NULL,NULL) != 0)
        ^
./Modules/posixmodule.c:7192:9: note: did you mean 'openat'?
/usr/include/sys/fcntl.h:516:5: note: 'openat' declared here
int     openat(int,const char *,int,...) __DARWIN_NOCANCEL(openat) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0);
        ^
./Modules/posixmodule.c:7192:9: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    if (openpty(&master_fd,NULL) != 0)
        ^
./Modules/posixmodule.c:7293:11: error: implicit declaration of function 'forkpty' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pid = forkpty(&master_fd,NULL);
          ^
./Modules/posixmodule.c:7293:11: warning: this function declaration is not a prototype [-Wstrict-prototypes]
2 warnings and 2 errors generated.
make: *** [Modules/posixmodule.o] Error 1
make: *** Waiting for unfinished jobs....

我的 Makefile 是通过运行以下命令生成的:

CPPFLAGS="-I$(brew --prefix zlib)/include" \
LDFLAGS="-L$(brew --prefix zlib)/lib" \
./configure --with-openssl=$(brew --prefix openssl) \
--with-pydebug

您知道什么可能是错误或遗漏的吗?

更新: 显然,这是一个已知且未解决的问题。 https://bugs.python.org/issue34027

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)