Hi,

In Fedora we have been shipping GCC 14 since Fedora 40; it turns out
that at this moment we can no longer compile against readline since
including readline.h failed, as FILE is defined in stdio.h and that is
no longer included by default.

Please find attached the patch that I have tested by building readline
with it locally and using it to compile jimtcl.

References:
readline RHBZ https://bugzilla.redhat.com/show_bug.cgi?id=2309495
jimtcl RHBZ https://bugzilla.redhat.com/show_bug.cgi?id=2309077

Best regards,

-- 
 _o) Michel Lind
_( ) identities: https://keyoxide.org/5dce2e7e9c3b1cffd335c1d78b229d2f7ccc04f2
From bf82479e738c433865291af158587c356f5091d8 Mon Sep 17 00:00:00 2001
From: Michel Lind <sali...@fedoraproject.org>
Date: Thu, 19 Sep 2024 10:11:49 +0200
Subject: [PATCH] Fix including readline.h on GCC 14 systems
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

stdio.h is no longer included by default, meaning including readline.h
fails because of undefined references to FILE

See https://bugzilla.redhat.com/show_bug.cgi?id=2309495

```
In file included from /usr/include/readline/readline.h:36,
                 from rdln.c:1:
/usr/include/readline/rltypedefs.h:71:29: error: unknown type name ‘FILE’
   71 | typedef int rl_getc_func_t (FILE *);
      |                             ^~~~
/usr/include/readline/rltypedefs.h:1:1: note: ‘FILE’ is defined in header 
‘<stdio.h>’; this is probably fixable by adding ‘#include <stdio.h>’
  +++ |+#include <stdio.h>
    1 | /* rltypedefs.h -- Type declarations for readline functions. */
/usr/include/readline/readline.h:450:21: error: unknown type name ‘FILE’
  450 | extern int rl_getc (FILE *);
      |                     ^~~~
/usr/include/readline/readline.h:39:1: note: ‘FILE’ is defined in header 
‘<stdio.h>’; this is probably fixable by adding ‘#include <stdio.h>’
   38 | #  include <readline/tilde.h>
  +++ |+#include <stdio.h>
   39 | #endif
...
```

Signed-off-by: Michel Lind <sali...@fedoraproject.org>
---
 readline.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/readline.h b/readline.h
index cac269f..52895ec 100644
--- a/readline.h
+++ b/readline.h
@@ -26,6 +26,8 @@
 extern "C" {
 #endif
 
+#include <stdio.h>
+
 #if defined (READLINE_LIBRARY)
 #  include "rlstdc.h"
 #  include "rltypedefs.h"
-- 
2.46.0

Attachment: signature.asc
Description: PGP signature

Reply via email to