From 8e258e150743f9d71a7bbd9f70af78a05d354456 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 6 Dec 2016 15:54:07 +0200 Subject: Work around wrong static initialization order in VC --- build2/variable | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'build2/variable') diff --git a/build2/variable b/build2/variable index 8fc1fb9..0480a6c 100644 --- a/build2/variable +++ b/build2/variable @@ -694,8 +694,15 @@ namespace build2 static void prepend (value&, vector&&); static bool empty (const vector& x) {return x.empty ();} - static const string type_name; - static const build2::value_type value_type; + // Make sure these are static-initialized together. Failed that VC will + // make sure it's done in the wrong order. + // + struct value_type_ex: build2::value_type + { + string type_name; + value_type_ex (value_type&&); + }; + static const value_type_ex value_type; }; // map @@ -713,8 +720,15 @@ namespace build2 return append (v, move (x));} static bool empty (const map& x) {return x.empty ();} - static const string type_name; - static const build2::value_type value_type; + // Make sure these are static-initialized together. Failed that VC will + // make sure it's done in the wrong order. + // + struct value_type_ex: build2::value_type + { + string type_name; + value_type_ex (value_type&&); + }; + static const value_type_ex value_type; }; // variable_pool -- cgit v1.1