From 8cab209ef91cbda34bae8afa880f152c4f1473b0 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Thu, 1 Oct 2015 17:35:26 +0200 Subject: [PUSB] Fix static initialization order fiasco For details see: https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use --- cores/arduino/PluggableUSB.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cores/arduino/PluggableUSB.h') diff --git a/cores/arduino/PluggableUSB.h b/cores/arduino/PluggableUSB.h index 824440a..b0668f4 100644 --- a/cores/arduino/PluggableUSB.h +++ b/cores/arduino/PluggableUSB.h @@ -66,7 +66,10 @@ private: PUSBListNode* rootNode; }; -extern PluggableUSB_ PluggableUSB; +// Replacement for global singleton. +// This function prevents static-initialization-order-fiasco +// https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use +PluggableUSB_& PluggableUSB(); #endif -- cgit v1.2.3-18-g5258