You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Kent Dahl <ke...@stud.ntnu.no> on 2001/01/12 09:52:16 UTC

Re: DOMString constructor causing a segmentation violation on Lin ux?

Bill Halchin wrote:
>       Yes I did. However array of DOMStrings are declared static. I
> guess with C++
> semantics that constructors for all static objects get executed before
> "main" gets
> executed  and by inference before XMLPlatformUtils::Initialize has a
> chance to get
> executed (I saw this because I saw this behavior in gdb!). If my
> observation is correct,
> i.e. about when constructors for statically-declared C++ objects are
> called, then what
> can I do?? Am I not allowedto have statically declared DOMString
> arrays??

One idea, is to use another statically allocated object which does the
XMLPlatformUtils initializing and terminating. (I currently use one, but
not for your intended purpose.)

Unfortunately, AFAIK you have little certainty of the sequence of
instantiation of static objects. But I do faintly recall something about
the sequence being deterministic inside single translation units. (.ie,
one .cpp, one .o) 

So a potential solution might be: Create a XMLInitializer class, which
counts the number of instantations and makes sure that Initialize is
called only once, and Terminate also only once, independant of the
number of XMLInitializer instanations. Then you might get away with
always having a static XMLInitializer object before any static DOMString
arrays.

Might be worth a shot, before doing the obvious: Giving up on DOMString
static arrays, and end up using static arrays of pointers to DOMString.

-- 
<[ Kent Dahl ]>================<[ http://www.stud.ntnu.no/~kentda/ ]>
  )____(stud.techn.;ind.øk.data)||(softwareDeveloper.at(Trustix))_( 
 /"Opinions expressed are mine and not those of my Employer,      "\
( "the University, my girlfriend, stray cats, banana fruitflies,  " )
 \"nor the frontal lobe of my left cerebral hemisphere.           "/