The following is a part of one of my source file:
struct s{char *p}; struct s code a = {"string1"}; struct s code b = {"string2"};
I don't know the answer to your question, but I just wanted to point out that your program should not rely on the memory allocation pattern of any particular compiler/linker. You can force memory allocation order by incorporating the variables into a bigger structure. - mike
Your suggestion is really constructive. Actually, the problem is originally relevant to structures with bi-direction linkages. In my design, the structures are too large to complie(error: segment too large) if they are dealed as variables when initializing them. So I have to use keyword 'code' to declare them as well as give values of their fields in them. But the linkage pointers can not be initialized correctly due to their declaring orders. e.g.
struct s{ char *p struct s *pre, *suc; }; struct s code a = {"string1", &b, &b }; // line 1 struct s code b = {"string2", &a, &a}; // line 2
Do this. It should work.
struct s{ char *p struct s *pre, *suc; }; struct s code b; struct s code a = {"string1", &b, &b }; // line 1 struct s code b = {"string2", &a, &a}; // line 2