[omniORB] Re: NT-Omnithreads: little bug (or annoying feature)

Sai-Lai Lo S.Lo@uk.research.att.com
21 Jul 1999 11:22:30 +0100


Jay,

I agree with you that trying to locate a macro clash can be a frustrating
experience. 

What you described is more a NT STL or VC bug rather than an omnithread
problem.

Your suggestion of putting a NOMINMAX in nt.h, while it fixes your problem,
may have the undesirable side-effect to someone who want to use min and max
macros from windows. They would be scratching their head to understand why
the compiler fails to recognise min and max.

What I tend to do in my code to deal with macro clash is to test ifdef of
the suspected macro and if it is defined and is going to clash with my
functions or some libraries I include, I'll undef it at that place.

Alternatively, one can always -DNOMINMAX as a command line option to the
compiler when one uses STL. Again you have complete control to do so
without relying on omnithread or any library headers to do that for you.

Thanks for pointing out the problem. I'm sure others on the mailing list
would benefit from your observation.

Sai-Lai


>>>>> Jay Wylie writes:

> It took two developers a fair chunk of time to figure this out, and I
> think you guys can easily fix it on your end.

> For Windows NT <omnithread.h> includes <nt.h> which in turn includes
> <windows.h>. Windows.h defines some macros for min and max. These
> conflict with templates defined in part of the STL and used in
> <valarray>. It is likely the templates are used elsewhere in the STL.

> In "nt.h", changing the first few lines from:
> #ifndef __omnithread_nt_h_
> #define __omnithread_nt_h_
> #include <windows.h>
> to:
> #ifndef __omnithread_nt_h_
> #define __omnithread_nt_h_
> #define NOMINMAX
> #include <windows.h>
> stops the macros defined in windows.h from clobbering the STL templates.

> Even if you don't want to add the define to "nt.h", some
> documentation/comments that on NT "windows.h" is included whenever
> "CORBA.H" is included would be helpful. It took us a few hours before we
> realized that deep into the omniORB header files, windows.h was
> included.

> Thanks,
> Jay

> --
> Jay Wylie                      Carnegie Mellon University
> Phone: (412) 268-5214          Institute for Complex Engineered Systems
> Email: jwylie+@cmu.edu         Hamburg Hall 1212
> http://www.cs.cmu.edu/~jwylie  Pittsburgh, PA 15213-3890




-- 
Sai-Lai Lo                                   S.Lo@uk.research.att.com
AT&T Laboratories Cambridge           WWW:   http://www.uk.research.att.com 
24a Trumpington Street                Tel:   +44 1223 343000
Cambridge CB2 1QA                     Fax:   +44 1223 313542
ENGLAND