Static initialization order
    Justin Johansson 
    no at spam.com
       
    Tue Feb  9 04:38:25 PST 2010
    
    
  
BCS wrote:
> Hello Justin,
>> Yes, well, that unfortunately is what I'm doing in my C++ project ..
>> putting implementation of all the static class declarations in one
>> big file.
> 
> could you do that same sort of things that you do with .h files?
Sorry, I'm not sure I understand your question.  For my problem,
.h files are not the issue;  the issue is about establishing the
correct order for statically constructed objects which exist in
.cpp files.  Hence the reason for one big .cpp file.
> void SomeStaticInitFunction()
> {
>   static bool once = false, done = false;
>   if(once) { assert(done); return; }
>   once = true;
> 
>   // call the StaticInitFunctions that you depend on:
> 
>   done = true;
> 
>   // do other stuff.  }
> 
> and then call the StaticInitFunctions whenever and wherever you want.
> 
> -- 
> <IXOYE><
    
    
More information about the Digitalmars-d
mailing list