[Ns-developers] ns-3 win32 port
mathieu.lacage at sophia.inria.fr
Mon Aug 20 03:38:01 PDT 2007
On Sun, 2007-08-19 at 23:01 -0700, Tom Henderson wrote:
> I am wondering whether there is any overall portability guidance that
> you can generalize from what you had to do to make this work, such as
> "avoid template-based local static variables"? Something that might
> complement or extend the application note that Craig put together on
"Avoid local static variables in function and method templates"
"Avoid static class member variables in class templates"
Of course, if you are really careful to instantiate these templates in
only one compilation unit, you should be safe but, it is a bit
complicated to figure out exactly when you are safe in that case. i.e.,
even though an early version of my win32 tree did this in a safe way, I
chose to avoid it in the end because I could not make myself feel
comfortable with it and I would not recommend trying to make it work.
> > There are a number of items I think we need to tackle to improve the
> > win32 port and these are summarized below:
> > - simplify the ComponentManager code by changing all static const
> > InterfaceId MyClass::iid to static InterfaceId iid (void); and the same
> > thing for cids. I do not believe that this change is strictly needed but
> > it will increase the robustness of the current code and that is a good
> > thing.
> Can you say a bit more about why you think the above will improve
It will be more robust because it will ensure very easily a proper
initialization ordering of InterfaceId and ClassId variables. It will
also simplify greatly the ComponentManager code which deals with these
types because the ComponentManager does a lot of scary things to avoid
these initialization ordering problems.
Generally speaking, it is clear that we should try to avoid global
static variables which contain non-trivial constructors to avoid these
initialization ordering problems and we should replace them with local
static variables when we can.
i.e., a good summary about this issue can be found there:
More information about the Ns-developers