OSDN Git Service

Add some compiler warnings and corresponding fixes.
authorCarl Worth <cworth@cworth.org>
Mon, 10 May 2010 20:17:25 +0000 (13:17 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 10 May 2010 20:32:29 +0000 (13:32 -0700)
Most of the current problems were (mostly) harmless things like
missing declarations, but there was at least one real error, (reversed
argument order for yyerrror).

Makefile
glcpp-lex.l
glcpp-parse.y
glcpp.c
glcpp.h [new file with mode: 0644]

index d8357dd..d0ca78d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+override CFLAGS += -Wall -Wextra -Wwrite-strings -Wswitch-enum -Wno-unused
+
 glcpp: glcpp.o glcpp-lex.o glcpp-parse.o
 
 %.c %.h: %.y
index 276f50d..747e240 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "glcpp.h"
 #include "glcpp-parse.h"
 %}
 
index 9acd549..a2d1094 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "glcpp.h"
+
 #define YYSTYPE int
 
 void
-yyerror (const char *error, void *scanner);
+yyerror (void *scanner, const char *error);
 
 %}
 
@@ -54,7 +56,7 @@ token:                TOKEN
 %%
 
 void
-yyerror (const char *error, void *scanner)
+yyerror (void *scanner, const char *error)
 {
        fprintf (stderr, "Parse error: %s\n", error);
 }
diff --git a/glcpp.c b/glcpp.c
index 90a0e89..eefac74 100644 (file)
--- a/glcpp.c
+++ b/glcpp.c
@@ -21,6 +21,8 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include "glcpp.h"
+
 int
 main (void)
 {
diff --git a/glcpp.h b/glcpp.h
new file mode 100644 (file)
index 0000000..485387b
--- /dev/null
+++ b/glcpp.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef GLCPP_H
+#define GLCPP_H
+
+/* Generated by glcpp-lex.l to glcpp-lex.c */
+
+#define yyscan_t void*
+
+int
+yylex_init (yyscan_t *scanner);
+
+int
+yylex (yyscan_t scanner);
+
+int
+yylex_destroy (yyscan_t scanner);
+
+/* Generated by glcpp-parse.y to glcpp-parse.c */
+
+int
+yyparse (void *scanner);
+
+#endif