Frank Heckenbach
Gert Doering wrote:
Out of curiosity: do you have any idea what's going on inside gpc/gcc here? Why is it breaking the *link* phase? Are various parts of the system disagreeing on the suffix number to use for the linker?
The problem is that such variables must be initialized. (For file types, it should be possible to do it via static initializers internally, and I might do this in the course of a future change, but not at the moment. For strings, it would theoretically be possible to use a static initializer as well, but since this would force the whole (often large) variable into the initialized data section and blow up executable sizes, I don't think this would be appreciated. So in general, I think we must assume that we need initialization code.)
IMHO for constants static initializer is preferable. In general case I agree -- code is more flexible.
Static variables must be initialized only once, even if they're local (otherwise they'd lose their values when the containing routine is called again which would defeat much of their purpose). I see two ways of doing it:
- Initialize them from the module/program constructor. That's what I'm doing now. The problem is that we have to violate the scoping internally, and apparently the current way is not correct since the AIX linker probably considers the variable to be initialized as different from the actual local variable and so runs into unresolved references.
AFAICS with qualified identifiers we can move static variables to global scope (mangle name and set DECL_CONTEXT to 0), which should avoid the problem.