• R/O
  • SSH
  • HTTPS

yash: 提交


Commit MetaInfo

修訂4200 (tree)
時間2022-08-20 15:16:59
作者magicant

Log Message

configure: Avoid compiler warnings in ncurses test

Recent versions of ncurses (at least version 6.2) have some function
prototype declarations different in parameter types. Because of the
incompatible-type warning, some tests in "configure" fail when compiled
with the -Werror option. This commit rewrites the test so it does not
produce warnings when it should succeed.

Change Summary

差異

--- yash/trunk/configure (revision 4199)
+++ yash/trunk/configure (revision 4200)
@@ -1,5 +1,5 @@
11 # Manually written configuration script for yash
2-# (C) 2007-2021 magicant
2+# (C) 2007-2022 magicant
33 #
44 # This program is free software: you can redistribute it and/or modify
55 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
3030
3131 target="yash"
3232 version="2.52"
33-copyright="Copyright (C) 2007-2021 magicant"
33+copyright="Copyright (C) 2007-2022 magicant"
3434
3535 # object files to be linked as `yash'
3636 objs='$(MAIN_OBJS)'
@@ -726,15 +726,24 @@
726726 #include <ncursesw/ncurses.h>
727727 #endif
728728 #include <${i%:*}>
729+int putchar(int);
730+
729731 int main(void) {
730- int (*f1)(char *, int, int *) = setupterm; f1("", 0, 0);
731- int (*f2)(char *) = tigetflag; f2("");
732- int (*f3)(char *) = tigetnum; f3("");
733- char *(*f4)(char *) = tigetstr; f4("");
734- int (*f5)(const char *, int, int (*)(int)) = tputs; f5("", 0, 0);
735-/* char *(*f6)(char *, long,long,long,long,long,long,long,long,long) = tparm;
736- f6("", 0, 0, 0, 0, 0, 0, 0, 0, 0); */
737- int (*f7)(TERMINAL *) = del_curterm; f7(cur_term);
732+/* Undeclared identifiers are a syntax error in C99, but many compilers assume
733+ * implicit declarations when they appear in a function call. We force compilers
734+ * to reject undeclared functions by using them in a non-call expression. */
735+(void) setupterm, (void) tigetflag, (void) tigetnum, (void) tigetstr;
736+(void) tparm, (void) tputs, (void) del_curterm, (void) cur_term;
737+
738+/* Check if we can actually call them with arguments of suitable types */
739+int i1 = setupterm("", 1, (int*)0);
740+int i2 = tigetflag("");
741+int i3 = tigetnum("");
742+char *s1 = tigetstr("");
743+char *s2 = tparm(s1, (long) i1, (long) i2, (long) i3, 0L, 0L, 0L, 0L, 0L, 0L);
744+int i4 = tputs(s2, 1, putchar);
745+(void) del_curterm(cur_term);
746+return i4;
738747 }
739748 END
740749 trycompile
Show on old repository browser