Idris2
                                
                                 Idris2 copied to clipboard
                                
                                    Idris2 copied to clipboard
                            
                            
                            
                        Failure to compile FFI-readline example on nix.
Hi. I get this error when I try to build the FFI-readline example.
[I] lc@aiur ~/S/g/i/I/s/FFI-readline (master) [127]> nix-shell -p readline --command 'idris2 --build readline.ipkg'
make: Entering directory '/home/lc/Source/github.com/idris-lang/Idris2/samples/FFI-readline/readline_glue'
gcc -Wall  -fPIC   -c -o idris_readline.o idris_readline.c
In file included from /nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/readline.h:35,
                 from idris_readline.c:1:
/nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/rltypedefs.h:71:28: error: unknown type name ‘FILE’
   71 | typedef int rl_getc_func_t PARAMS((FILE *));
      |                            ^~~~~~
In file included from /nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/readline.h:36,
                 from idris_readline.c:1:
/nix/store/ahsfc5f18l7y25ykp10cp6wfqcp5qwvq-readline-6.3p08-dev/include/readline/rltypedefs.h:1:1: note: ‘FILE’ is defined in header ‘<stdio.h>’; did you forget to ‘#include <stdio.h>’?
  +++ |+#include <stdio.h>
We don't seem to have continuous integration for the content of samples/.
Still, I was able to compile the file on ubuntu after installing libreadline-dev.
Could it be that this is an upstream issue in the readline package nix uses?
That seems likely.
Looks like it's in readline. The manpages imply you have to manually #include <stdio.h> first. At least Arch and NixOS have this issue, so maybe Ubuntu modifies libreadline-dev?
Adding that line allows me to build in NixOS.
Okay I've tried adding this extra line too and it does not break the build on Ubuntu AFAICT.
I'll be happy to merge a PR including that line & adding samples to the CI.
Given that it seems this was an issue in the nix repo, maybe it is worth revisiting whether this is still an issue over a year later.