From 2a42511c5c1cbe9ee1ce1dcc4aefbff178d8ca2b Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 17 Nov 2015 19:18:55 -0500 Subject: [PATCH] Fixed an assortment of C++ and Haiku build errors. --- GNUbaserules.mk | 2 ++ common/uipriv.h | 8 ++++++++ haiku/GNUmakeinc.mk | 2 +- haiku/alloc.cpp | 14 +++++++------- haiku/uipriv_haiku.hpp | 4 +++- 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/GNUbaserules.mk b/GNUbaserules.mk index 42d8ffe2..2550e3f9 100644 --- a/GNUbaserules.mk +++ b/GNUbaserules.mk @@ -15,6 +15,8 @@ CFLAGS += \ -Wno-switch \ --std=c99 +# TODO consider switching to C++11 +# this will hopelessly disbar Haiku for GCC 2 CXXFLAGS += \ -g \ -Wall -Wextra \ diff --git a/common/uipriv.h b/common/uipriv.h index a8cf9273..e95762dd 100644 --- a/common/uipriv.h +++ b/common/uipriv.h @@ -1,4 +1,8 @@ // 6 april 2015 +#ifdef __cplusplus +extern "C" { +#endif + #include #define uthash_fatal(msg) complain("uthash failed: %s", (msg)) @@ -70,3 +74,7 @@ extern void fallbackScale(uiDrawMatrix *, double, double, double, double); extern void fallbackMultiply(uiDrawMatrix *, uiDrawMatrix *); extern void fallbackTransformPoint(uiDrawMatrix *, double *, double *); extern void fallbackTransformSize(uiDrawMatrix *, double *, double *); + +#ifdef __cplusplus +} +#endif diff --git a/haiku/GNUmakeinc.mk b/haiku/GNUmakeinc.mk index 676b4d11..b3d47df3 100644 --- a/haiku/GNUmakeinc.mk +++ b/haiku/GNUmakeinc.mk @@ -16,7 +16,7 @@ CXXFLAGS += \ LDFLAGS += \ -fvisibility=hidden \ -fPIC \ - -lbe -lm + -lbe # flags for warning on undefined symbols LDFLAGS += \ diff --git a/haiku/alloc.cpp b/haiku/alloc.cpp index 6e044911..ced5db2b 100644 --- a/haiku/alloc.cpp +++ b/haiku/alloc.cpp @@ -3,7 +3,7 @@ #include #include #include "uipriv_haiku.hpp" -using namepsace std; +using namespace std; static set allocations; @@ -48,23 +48,23 @@ void *uiAlloc(size_t size, const char *type) return DATA(out); } -void *uiRealloc(void *p, size_t new, const char *type) +void *uiRealloc(void *p, size_t xnew, const char *type) { void *out; size_t *s; if (p == NULL) - return uiAlloc(new, type); + return uiAlloc(xnew, type); p = BASE(p); - out = realloc(p, EXTRA + new); + out = realloc(p, EXTRA + xnew); if (out == NULL) { fprintf(stderr, "memory exhausted in uiRealloc()\n"); abort(); } s = SIZE(out); - if (new <= *s) - memset(((uint8_t *) DATA(out)) + *s, 0, new - *s); - *s = new; + if (xnew <= *s) + memset(((uint8_t *) DATA(out)) + *s, 0, xnew - *s); + *s = xnew; // TODO check this allocations.erase(p); allocations.insert(out); diff --git a/haiku/uipriv_haiku.hpp b/haiku/uipriv_haiku.hpp index 65449dfe..d7684000 100644 --- a/haiku/uipriv_haiku.hpp +++ b/haiku/uipriv_haiku.hpp @@ -1,7 +1,9 @@ // 17 november 2015 // TODO versioning macros? +#include #include -#include "../ui.h" +//TODO#include "../ui.h" +#include "ui.hpp" #include "../ui_haiku.hpp" #include "../common/uipriv.h"