From cc8b6aa3d937dda055cb25fdbec55d0afb6be2a0 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Tue, 21 Apr 2020 12:47:56 +0200 Subject: scanner: Guard interface declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to include client and server headers in the same file fixing warnings like In file included from ../subprojects/wlroots/include/wlr/types/wlr_layer_shell_v1.h:16, from ../src/desktop.h:16, from ../src/server.h:13, from ../tests/testlib.c:8: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-protocol.h:80:34: warning: redundant redeclaration of ‘zwlr_layer_shell_v1_interface’ [-Wredundant-decls] 80 | extern const struct wl_interface zwlr_layer_shell_v1_interface; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../tests/testlib.h:8, from ../tests/testlib.c:7: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-client-protocol.h:77:34: note: previous declaration of ‘zwlr_layer_shell_v1_interface’ was here 77 | extern const struct wl_interface zwlr_layer_shell_v1_interface; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../subprojects/wlroots/include/wlr/types/wlr_layer_shell_v1.h:16, from ../src/desktop.h:16, from ../src/server.h:13, from ../tests/testlib.c:8: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-protocol.h:106:34: warning: redundant redeclaration of ‘zwlr_layer_surface_v1_interface’ [-Wredundant-decls] 106 | extern const struct wl_interface zwlr_layer_surface_v1_interface; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../tests/testlib.h:8, from ../tests/testlib.c:7: tests/59830eb@@footest@sta/wlr-layer-shell-unstable-v1-client-protocol.h:103:34: note: previous declaration of ‘zwlr_layer_surface_v1_interface’ was here 103 | extern const struct wl_interface zwlr_layer_surface_v1_interface; Signed-off-by: Guido Günther Closes: #158 --- src/scanner.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/scanner.c') diff --git a/src/scanner.c b/src/scanner.c index b470c91..36ac905 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -1636,6 +1636,8 @@ emit_header(struct protocol *protocol, enum side side) printf("\n"); wl_list_for_each(i, &protocol->interface_list, link) { + printf("#ifndef %s_INTERFACE\n", i->uppercase_name); + printf("#define %s_INTERFACE\n", i->uppercase_name); printf("/**\n" " * @page page_iface_%s %s\n", i->name, i->name); @@ -1656,6 +1658,7 @@ emit_header(struct protocol *protocol, enum side side) printf(" */\n"); printf("extern const struct wl_interface " "%s_interface;\n", i->name); + printf("#endif\n"); } printf("\n"); -- cgit v1.2.3-70-g09d2