[PATCH 09/13] manual: Fix missing declaration in setjmp example.
Collin Funk
collin.funk1@gmail.com
Sun Sep 28 22:46:02 GMT 2025
Previously this file would fail to compile with the following error:
$ gcc manual/examples/setjmp.c
manual/examples/setjmp.c: In function ‘main’:
manual/examples/setjmp.c:37:7: error: implicit declaration of function ‘do_command’ [-Wimplicit-function-declaration]
37 | do_command ();
| ^~~~~~~~~~
manual/examples/setjmp.c: At top level:
manual/examples/setjmp.c:42:1: warning: conflicting types for ‘do_command’; have ‘void(void)’
42 | do_command (void)
| ^~~~~~~~~~
manual/examples/setjmp.c:37:7: note: previous implicit declaration of ‘do_command’ with type ‘void(void)’
37 | do_command ();
| ^~~~~~~~~~
---
manual/examples/setjmp.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/manual/examples/setjmp.c b/manual/examples/setjmp.c
index 95e328d401..3c7d97937e 100644
--- a/manual/examples/setjmp.c
+++ b/manual/examples/setjmp.c
@@ -27,17 +27,6 @@ abort_to_main_loop (int status)
longjmp (main_loop, status);
}
-int
-main (void)
-{
- while (1)
- if (setjmp (main_loop))
- puts ("Back at main loop....");
- else
- do_command ();
-}
-
-
void
do_command (void)
{
@@ -47,3 +36,13 @@ do_command (void)
else
exit (EXIT_SUCCESS);
}
+
+int
+main (void)
+{
+ while (1)
+ if (setjmp (main_loop))
+ puts ("Back at main loop....");
+ else
+ do_command ();
+}
--
2.51.0
More information about the Libc-alpha
mailing list