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.
@@ -1,5 +1,5 @@ | ||
1 | 1 | # Manually written configuration script for yash |
2 | -# (C) 2007-2021 magicant | |
2 | +# (C) 2007-2022 magicant | |
3 | 3 | # |
4 | 4 | # This program is free software: you can redistribute it and/or modify |
5 | 5 | # it under the terms of the GNU General Public License as published by |
@@ -30,7 +30,7 @@ | ||
30 | 30 | |
31 | 31 | target="yash" |
32 | 32 | version="2.52" |
33 | -copyright="Copyright (C) 2007-2021 magicant" | |
33 | +copyright="Copyright (C) 2007-2022 magicant" | |
34 | 34 | |
35 | 35 | # object files to be linked as `yash' |
36 | 36 | objs='$(MAIN_OBJS)' |
@@ -726,15 +726,24 @@ | ||
726 | 726 | #include <ncursesw/ncurses.h> |
727 | 727 | #endif |
728 | 728 | #include <${i%:*}> |
729 | +int putchar(int); | |
730 | + | |
729 | 731 | 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; | |
738 | 747 | } |
739 | 748 | END |
740 | 749 | trycompile |