Skip to content

Static Initialization Order Fiasco

“Static Initialization Order Fiasco”即“静态初始化顺序失败”。

What is Static Initialization Order Fiasco

在下面文章中,讨论了"Static Initialization Order Fiasco"

1、isocpp What’s the “static initialization order ‘fiasco’ (problem)”? Δ

To prevent the static initialization order problem, use the Construct On First Use Idiom, described below.

2、参见 Construct-On-First-Use-Idiom 章节。

3、stackoverflow extern vs Singleton class # A

4、pabloariasal C++ - Initialization of Static Variables

stackoverflow Prevent static initialization order “fiasco”, C++

A

The modern, more pattern-oriented way is *not to use globals in the first place*.

There's no other way around it.

It wouldn't be much of a "fiasco", otherwise!

NOTE: 关于global 和 singleton,参见 Global-VS-singleton 章节

TODO

stackoverflow Finding C++ static initialization order problems