# HG changeset patch # User John Tsiombikas # Date 1423581690 -7200 # Node ID 49a2e70ac455cfd69b51c8097facd68c6976cca4 # Parent 66d1762eb2038ba4e000519a1f2d165692f3aeaa foo diff -r 66d1762eb203 -r 49a2e70ac455 Makefile --- a/Makefile Thu Feb 05 23:20:20 2015 +0200 +++ b/Makefile Tue Feb 10 17:21:30 2015 +0200 @@ -5,8 +5,8 @@ warn = -pedantic -Wall dbg = -g -CXXFLAGS = $(warn) $(dbg) -LDFLAGS = $(libgl) -lm -lvmath +CXXFLAGS = -std=c++11 $(warn) $(dbg) +LDFLAGS = $(libgl) -lm -lvmath -lpthread ifeq ($(shell uname -s), Darwin) libgl = -framework OpenGL -framework GLUT -lGLEW diff -r 66d1762eb203 -r 49a2e70ac455 src/comp.cc --- a/src/comp.cc Thu Feb 05 23:20:20 2015 +0200 +++ b/src/comp.cc Tue Feb 10 17:21:30 2015 +0200 @@ -1,7 +1,9 @@ +#include #include #include #include "comp.h" +static std::map *early_comp_cons; static std::map comp_cons; Component::Component() @@ -32,14 +34,24 @@ void register_component(const char *name, Component *(*cons_func)()) { - if(!comp_cons[name]) { + if(!early_comp_cons) { + early_comp_cons = new std::map; + } + + if(!(*early_comp_cons)[name]) { printf("register component: %s\n", name); - comp_cons[name] = cons_func; + (*early_comp_cons)[name] = cons_func; } } Component *create_component(const char *name) { + if(early_comp_cons) { + comp_cons = std::move(*early_comp_cons); + delete early_comp_cons; + early_comp_cons = 0; + } + Component *(*cons)() = comp_cons[name]; if(cons) { return cons();