You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incompatible function pointer types assigning to 'Function *' at readline module #105323
changed the title [-]ncompatible function pointer types assigning to 'Function *' at readline module[/-][+]Incompatible function pointer types assigning to 'Function *' at readline module[/+]on Jun 5, 2023
Hi Ned,
AFAIK, Apple uses a different readline implementation from GNU and I checked API signatures were the same across versions. https://github.com/phracker/MacOSX-SDKs
So we can easily solve this issue by using a conditional compile approach.
If you grep for READLINE in configure.ac, you'll find that the dependency resolver for readline is more complex than that for other extension modules with third party dependencies. See also the WITH_EDITLINE conditional at the top of Modules/readline.c :)
I tried to link libedit on Ubuntu and it has the same issue.
sudo apt install libedit-dev
./configure --with-readline=editline
make
gcc -pthread -I/usr/include/editline -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I./Include/internal/mimalloc -I. -I./Include -fPIC -c ./Modules/readline.c -o Modules/readline.o
./Modules/readline.c: In function ‘setup_readline’:
./Modules/readline.c:1309:21: warning: assignment to ‘int (*)(const char *, int)’ from incompatible pointer type ‘int (*)(void)’ [-Wincompatible-pointer-types]
1309 | rl_startup_hook = on_startup_hook;
| ^
./Modules/readline.c:1311:23: warning: assignment to ‘int (*)(const char *, int)’ from incompatible pointer type ‘int (*)(void)’ [-Wincompatible-pointer-types]
1311 | rl_pre_input_hook = on_pre_input_hook;
| ^
We only use two headers, <editline/readline.h> if with-readline=editline and <readline/readline.h> if with-readline=readline (default). I think <editline/readline.h> always uses the "old" declaration with typedef int Function(const char *, int);.
I was wondering if we need WITH_APPLE_EDITLINE. _RL_FUNCTION_TYPEDEF seems to be the macro to indicate that the rl_* functions have the new style declarations, and the corresponding "old style" is the one with Function.
I was wondering if we need WITH_APPLE_EDITLINE. RL_FUNCTION_TYPEDEF seems to be the macro to indicate that the rl* functions have the new style declarations, and the corresponding "old style" is the one with Function.
Okay if this issue is happening outside of macOS too. We can use your suggestion for this issue.
The patch itself tried to reduce impact to outside of macOS.
Yeah I'll do it. As WITH_APPLE_EDITLINE is only used for this, should I just basically revert all the changes in #108665? The docs change to --with-readline should be kept I presume. Anything else?
Activity
[-]ncompatible function pointer types assigning to 'Function *' at readline module[/-][+]Incompatible function pointer types assigning to 'Function *' at readline module[/+]pythongh-105323: Suppress function pointer warning by type casting
corona10 commentedon Jun 30, 2023
Header from apple Xcode.
erlend-aasland commentedon Aug 17, 2023
@corona10, did you get any further with this? I'm getting annoyed at these warnings, myself :)
corona10 commentedon Aug 18, 2023
@erlend-aasland I will try to solve this issue at this weekend ;)
corona10 commentedon Aug 18, 2023
@ned-deily cc @erlend-aasland
Hi Ned,
AFAIK, Apple uses a different readline implementation from GNU and I checked API signatures were the same across versions.
https://github.com/phracker/MacOSX-SDKs
So we can easily solve this issue by using a conditional compile approach.
But if we have to care about linking with the GNU version on the macOS, the problem will be more difficult.
So we need to know that we should care or not.
https://stackoverflow.com/questions/7214374/how-do-i-link-against-the-gnu-readline-library-rather-than-libedit-in-macosx
erlend-aasland commentedon Aug 21, 2023
You can use the preprocessor define
WITH_EDITLINEto check if we're compiling with editline or readline.corona10 commentedon Aug 21, 2023
Wow, That's good! I will prepare the patch by this weekend :)
erlend-aasland commentedon Aug 21, 2023
If you grep for
READLINEinconfigure.ac, you'll find that the dependency resolver forreadlineis more complex than that for other extension modules with third party dependencies. See also theWITH_EDITLINEconditional at the top ofModules/readline.c:)erlend-aasland commentedon Aug 29, 2023
See discussion on #108588
pythongh-105323: Introduce --with-readline=apple option
corona10 commentedon Aug 31, 2023
For reference what I investigated
erlend-aasland commentedon Aug 31, 2023
Ok, it looks like the libedit I linked to would be unusable with CPython, so we can disregard that.
3 remaining items
gaogaotiantian commentedon Nov 29, 2023
I think this issue impacts more than MacOS.
I tried to link libedit on Ubuntu and it has the same issue.
We only use two headers,
<editline/readline.h>ifwith-readline=editlineand<readline/readline.h>ifwith-readline=readline(default). I think<editline/readline.h>always uses the "old" declaration withtypedef int Function(const char *, int);.I was wondering if we need
WITH_APPLE_EDITLINE._RL_FUNCTION_TYPEDEFseems to be the macro to indicate that the rl_* functions have the new style declarations, and the corresponding "old style" is the one withFunction.I think we should do something like
corona10 commentedon Nov 29, 2023
Okay if this issue is happening outside of macOS too. We can use your suggestion for this issue.
The patch itself tried to reduce impact to outside of macOS.
corona10 commentedon Nov 29, 2023
@gaogaotiantian Do you want to submit the patch?
gaogaotiantian commentedon Nov 29, 2023
Yeah I'll do it. As
WITH_APPLE_EDITLINEis only used for this, should I just basically revert all the changes in #108665? The docs change to--with-readlineshould be kept I presume. Anything else?corona10 commentedon Nov 29, 2023
Just remove WITH_APPLE_EDITLINE please
corona10 commentedon Nov 29, 2023
Two things are needed.
WITH_APPLE_EDITLINEfrom configure.ac and regendeate configure file.#elif defined(WITH_APPLE_EDITLINE)to#elsegaogaotiantian commentedon Nov 29, 2023
Done in #112513
gh-105323: Remove `WITH_APPLE_EDITLINE` to use the same declaration f…
erlend-aasland commentedon Dec 5, 2023
Can this be closed, @corona10?
corona10 commentedon Dec 5, 2023
Yeah sure!
pythongh-105323: Remove `WITH_APPLE_EDITLINE` to use the same declara…
pythongh-105323: Update readline module to detect apple editline vari…
pythongh-105323: Remove `WITH_APPLE_EDITLINE` to use the same declara…