Open ryandesign opened 1 year ago
While this PR makes the code compile successfully with GNU readline 8.1.2.000 (and -ledit
in bin/CMakeLists.txt should be changed to -lreadline
as well; see #54), it also makes the code fail to compile with the "readline compatible" libedit included in macOS 12.3.1 with the unsurprising reverse error message
/path/to/mpw-022d4cffe99e2a0f991182196491cba434e842a1/bin/debugger.cpp:1229:34: error: incompatible function pointer types assigning to 'Function *' (aka 'int (*)(const char *, int)') from 'rl_compentry_func_t *' (aka 'char *(*)(const char *, int)')
rl_completion_entry_function = (rl_compentry_func_t *)mpw_completion_entry_function;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
I'm not sure how one is meant to write software that is compatible with both readline and editline. It doesn't help that there appear to be several different projects calling themselves "libedit" or "editline".
When I was working on linux port, I did this:
#if RL_READLINE_VERSION == 0x0402
/* actually libedit */
rl_completion_entry_function = (Function *)mpw_completion_entry_function;
#else
/* gnu readline, I presume */
rl_completion_entry_function = mpw_completion_entry_function;
#endif
For another project that handled both, I did this, which is cleaner:
rl_completion_entry_function = reinterpret_cast<decltype(rl_completion_entry_function)>(mpw_completion_entry_function);
This PR fixes the following errors I got when trying to compile the latest code on macOS 12.3.1 with readline 8.1.2.000 installed (using MacPorts):
Function *
is an ancient readline type which no longer exists.Function *
and friends were deprecated in readline 4.2 (released April 2001) and removed in readline 6.3 (released February 2014).The
add_history
andcurrent_history
functions and theHIST_ENTRY
type appear to be defined in<readline/history.h>
which I guess needs to be included separately now.