From 83c2013dfbe4c0a3f15be6b8cbd255787d774de0 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Wed, 26 Nov 2014 14:03:05 -0800 Subject: [PATCH] Fixes to make GCC happier. --- Makefile | 4 ++-- src/main.c | 6 ++++++ src/wren_compiler.c | 3 +++ src/wren_value.c | 2 +- src/wren_value.h | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 692da17f..3f910c43 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ debug: prep wrend # Debug command-line interpreter. wrend: $(DEBUG_OBJECTS) - $(CC) $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -o wrend $^ + $(CC) $(CFLAGS) $(DEBUG_CFLAGS) -Iinclude -lm -o wrend $^ # Debug object files. build/debug/%.o: src/%.c include/wren.h $(HEADERS) @@ -38,7 +38,7 @@ release: prep wren # Release command-line interpreter. wren: $(RELEASE_OBJECTS) - $(CC) $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -o wren $^ + $(CC) $(CFLAGS) $(RELEASE_CFLAGS) -Iinclude -lm -o wren $^ # Release object files. build/release/%.o: src/%.c include/wren.h $(HEADERS) diff --git a/src/main.c b/src/main.c index 55f3b1fc..8be07ba1 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,5 @@ +#define _GNU_SOURCE // Makes getline() available in GCC. + #include #include #include @@ -56,6 +58,10 @@ static int runFile(WrenVM* vm, const char* path) case WREN_RESULT_SUCCESS: result = 0; break; case WREN_RESULT_COMPILE_ERROR: result = 65; break; // EX_DATAERR. case WREN_RESULT_RUNTIME_ERROR: result = 70; break; // EX_SOFTWARE. + default: + // Unreachable. + result = 255; + break; } wrenFreeVM(vm); diff --git a/src/wren_compiler.c b/src/wren_compiler.c index 3c05aed2..2be8055a 100644 --- a/src/wren_compiler.c +++ b/src/wren_compiler.c @@ -2248,6 +2248,9 @@ static int getNumArguments(const uint8_t* bytecode, const Value* constants, // There are two bytes for the constant, then two for each upvalue. return 2 + (loadedFn->numUpvalues * 2); } + + default: + UNREACHABLE(); } } diff --git a/src/wren_value.c b/src/wren_value.c index b7c6f034..9d262bb2 100644 --- a/src/wren_value.c +++ b/src/wren_value.c @@ -159,7 +159,7 @@ ObjFiber* wrenNewFiber(WrenVM* vm, Obj* fn) ObjFn* wrenNewFunction(WrenVM* vm, Value* constants, int numConstants, int numUpvalues, int numParams, - u_int8_t* bytecode, int bytecodeLength, + uint8_t* bytecode, int bytecodeLength, ObjString* debugSourcePath, const char* debugName, int debugNameLength, int* sourceLines) diff --git a/src/wren_value.h b/src/wren_value.h index 8ccfb12c..ba0ce655 100644 --- a/src/wren_value.h +++ b/src/wren_value.h @@ -564,7 +564,7 @@ ObjFiber* wrenNewFiber(WrenVM* vm, Obj* fn); // copy [constants] into its own array. ObjFn* wrenNewFunction(WrenVM* vm, Value* constants, int numConstants, int numUpvalues, int numParams, - u_int8_t* bytecode, int bytecodeLength, + uint8_t* bytecode, int bytecodeLength, ObjString* debugSourcePath, const char* debugName, int debugNameLength, int* sourceLines);