Top "Static-initialization" questions

Questions regarding initialization code of static members

How to fill a Javascript object literal with many static key/value pairs efficiently?

The typical way of creating a Javascript object is the following: var map = new Object(); map[myKey1] = myObj1; map[myKey2] = …

javascript object-literal static-initialization
Java: When is a static initialization block useful?

What's the difference between initialization within a static block: public class staticTest { static String s; static int n; static double …

java static-initialization
Static pthreads mutex initialization

Using pthreads, how would one, in C, initialize a static array of mutexes? For a single static mutex, it seems …

c pthreads mutex static-initialization
Spring static initialization of a bean

Hey, how one should deal with static initializations in Spring ? I mean, my bean has a static initialization private static …

spring static static-initialization
How can I run a static initializer method in C# before the Main() method?

Given a static class with an initializer method: public static class Foo { // Class members... internal static init() { // Do some initialization... } } …

c# .net static-methods static-classes static-initialization
static initialization in interface

When I tried to write something like this: public interface MyInterface { static { System.out.println("Hello!"); } } the compiler could not …

java interface static-initialization
Default value for struct parameter

Let's say I have the following struct: struct myStruct { int x; int y; int z; int w; }; I want to …

c++ struct initialization default-value static-initialization
g++, static initialization and -nostdlib

Compiling / linking with -nostdlib seems to prevent static initialization, even if I add my own crti.s and crtn.s …

gcc g++ static-initialization
C++ static initialization vs __attribute__((constructor))

Example: struct Foo { Foo() { printf("foo\n"); } }; static Foo foo; __attribute__((constructor)) static void _bar() { printf("bar\n"); } Is it …

c++ gcc static-initialization
How to force gcc to link unreferenced, static C++ objects from a library

I'm using a C++ library that can be built as either a shared or a static library. This library uses …

c++ linux gcc static-linking static-initialization