From 08263e367676071cae36941ab9186ab652b1406f Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Thu, 15 Jan 2015 16:00:51 -0800 Subject: [PATCH] Get debug and utils compiling as C++. --- src/wren_debug.c | 2 +- src/wren_utils.c | 3 ++- src/wren_utils.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wren_debug.c b/src/wren_debug.c index 3fd6a1c3..ce32f1ae 100644 --- a/src/wren_debug.c +++ b/src/wren_debug.c @@ -36,7 +36,7 @@ static int debugPrintInstruction(WrenVM* vm, ObjFn* fn, int i, int* lastLine) { int start = i; uint8_t* bytecode = fn->bytecode; - Code code = bytecode[i]; + Code code = (Code)bytecode[i]; int line = fn->debug->sourceLines[i]; if (lastLine == NULL || *lastLine != line) diff --git a/src/wren_utils.c b/src/wren_utils.c index 8486e85d..87e033aa 100644 --- a/src/wren_utils.c +++ b/src/wren_utils.c @@ -25,7 +25,8 @@ void wrenSymbolTableClear(WrenVM* vm, SymbolTable* symbols) int wrenSymbolTableAdd(WrenVM* vm, SymbolTable* symbols, const char* name, size_t length) { - char* heapString = wrenReallocate(vm, NULL, 0, sizeof(char) * (length + 1)); + char* heapString = (char*)wrenReallocate(vm, NULL, 0, + sizeof(char) * (length + 1)); strncpy(heapString, name, length); heapString[length] = '\0'; diff --git a/src/wren_utils.h b/src/wren_utils.h index 94e693ad..ba6c668c 100644 --- a/src/wren_utils.h +++ b/src/wren_utils.h @@ -34,12 +34,13 @@ wrenReallocate(vm, buffer->data, 0, 0); \ wren##name##BufferInit(vm, buffer); \ } \ + \ void wren##name##BufferWrite(WrenVM* vm, name##Buffer* buffer, type data) \ { \ if (buffer->capacity < buffer->count + 1) \ { \ int capacity = buffer->capacity == 0 ? 8 : buffer->capacity * 2; \ - buffer->data = wrenReallocate(vm, buffer->data, \ + buffer->data = (type*)wrenReallocate(vm, buffer->data, \ buffer->capacity * sizeof(type), capacity * sizeof(type)); \ buffer->capacity = capacity; \ } \