Artifact 18cd3f3736ceb7772b9c419a4114999d2da3a77a0680d0e23a91fcb8cc136e8b:
- File
src/init.mm
— part of check-in
[1ee33c9983]
at
2024-08-03 14:50:31
on branch trunk
— Don't depend on global constructors for commands
This breaks when using ObjC, as these can run before the ObjC module is initialized, resulting in non-working message sends as the selectors are not registered yet. (user: js, size: 338) [annotate] [blame] [check-ins using]
#include <vector> #import "cube.h" #import "protos.h" static std::vector<void (^)(void)> *queue; void enqueueInit(const char *name, void (^init)(void)) { if (queue == NULL) queue = new std::vector<void (^)(void)>(); queue->push_back(init); } void processInitQueue(void) { for (auto &init : *queue) init(); queue->clear(); }