4 ms·
C does have initialization of local variables, including static. It does not have any thread safety in standard for these, however, so no thread safe singletons
by AstralStorm 4y ago
C does have initialization of local variables, including static.
It does not have any thread safety in standard for these, however, so no thread safe singletons. (You can get them initialized by linker or runtime safely, of course, e.g. ELF .bss and UCRT on Windows)
You can use atomics to implement such a singleton if they are available.
This is one of the main reasons why C is more portable than C++.