[PATCH wayland 1/3] scanner: move include directives before extern "C" wrapper

Emil Velikov emil.l.velikov at gmail.com
Sun Apr 17 11:29:22 UTC 2016


Adding extern "C" wrapper before includes (especially system ones) is
illadvised as the headers themselves can behave diffently in that case.

See the section "Including C Headers in C++ Code" in the following
http://www.oracle.com/technetwork/articles/servers-storage-dev/mixingcandcpluspluscode-305840.html

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/scanner.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index 65df3ae..52c07a6 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1423,13 +1423,13 @@ emit_header(struct protocol *protocol, enum side side)
 	printf("#ifndef %s_%s_PROTOCOL_H\n"
 	       "#define %s_%s_PROTOCOL_H\n"
 	       "\n"
+	       "#include <stdint.h>\n"
+	       "#include <stddef.h>\n"
+	       "#include \"%s\"\n\n"
 	       "#ifdef  __cplusplus\n"
 	       "extern \"C\" {\n"
 	       "#endif\n"
 	       "\n"
-	       "#include <stdint.h>\n"
-	       "#include <stddef.h>\n"
-	       "#include \"%s\"\n\n"
 	       "struct wl_client;\n"
 	       "struct wl_resource;\n\n",
 	       protocol->uppercase_name, s,
-- 
2.8.0



More information about the wayland-devel mailing list