aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2014-05-20 07:58:13 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2014-05-20 07:58:13 +0300
commit7702272fdd9cbb09c55d45e78cce18c57916b46b (patch)
tree384c9602533bc887a6d9de9a71dd11cf593bb0c5
parent66054b79b24a7e639a5c65771005da9af5627465 (diff)
downloadlispish-7702272fdd9cbb09c55d45e78cce18c57916b46b.tar.gz
lispish-7702272fdd9cbb09c55d45e78cce18c57916b46b.zip
use -Wextra when compiling and fix some warnings produced by it
-rw-r--r--Makefile2
-rw-r--r--atom.c10
-rw-r--r--eval.c3
-rw-r--r--repl.c2
4 files changed, 12 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 5771671..d542721 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ SOURCES = parse.c atom.c eval.c tokens.c env.c
OBJECTS = $(SOURCES:.c=.o)
TEST_OBJECTS = $(foreach obj,$(OBJECTS),test_$(obj))
-CFLAGS = -Wall -g
+CFLAGS = -Wall -Wextra -g
LDFLAGS =
CC = gcc
diff --git a/atom.c b/atom.c
index 43626d8..e3de9ce 100644
--- a/atom.c
+++ b/atom.c
@@ -6,15 +6,19 @@
#include <string.h>
#include <stdarg.h>
-struct atom true_atom = { ATOM_TRUE };
-struct atom false_atom = { ATOM_FALSE };
-struct atom nil_atom = { ATOM_NIL } ;
+struct atom true_atom;
+struct atom false_atom;
+struct atom nil_atom;
__attribute__((constructor))
static void setup_builtin_atoms()
{
nil_atom.list = calloc(1, sizeof(*nil_atom.list));
LIST_INIT(nil_atom.list);
+
+ true_atom.type = ATOM_TRUE;
+ false_atom.type = ATOM_FALSE;
+ nil_atom.type = ATOM_NIL;
}
struct atom *atom_new(char type)
diff --git a/eval.c b/eval.c
index 8325c1f..89b6730 100644
--- a/eval.c
+++ b/eval.c
@@ -75,6 +75,7 @@ struct atom *builtin_quote(struct atom *expr, struct env *env)
{
struct list *list = expr->list;
struct atom *op = LIST_FIRST(list);
+ (void) env;
return atom_clone(LIST_NEXT(op, entries));
}
@@ -84,6 +85,8 @@ struct atom *builtin_atom(struct atom *expr, struct env *env)
struct atom *op = LIST_FIRST(list);
struct atom *a = LIST_NEXT(op, entries);
+ (void) env;
+
if (!a)
return &nil_atom;
diff --git a/repl.c b/repl.c
index c9d6861..ea8d744 100644
--- a/repl.c
+++ b/repl.c
@@ -8,7 +8,7 @@
#include "atom.h"
#include "linenoise.h"
-int main(int argc, char **argv)
+int main()
{
char *line;
struct env *env;