openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-devel] few days too late..


From: Jukka Liimatta
Subject: [Openexr-devel] few days too late..
Date: Sun, 26 Jan 2003 14:00:01 +0200

I posted this days ago, but didn't notice it bounced until today as read my
mails for past few days from work address. I repost, even though I believe
these issues have been discussed to resolution already. Just  my $.02's
worth, even if late. ;-)

I would also be interested in the latest updates to the source tree so that
I catch up with the rest (regarding the Windows port), so that I wouldn't
comment on old issues like these too much in the future ("cathing up").


> >  > The template followed by a template causes a syntax error.  This is a
> >  > bug with the compiler, which I'll try reporting to Microsoft.
> >
> > try template <class T, class S>, should be the same
>
> I'd tried this, but these actually aren't the same thing.  A template
> parameter list of a template and its template member cannot be conbined,
> so there isn't going to be a simple work around for this with the
> current Microsoft compiler.

I'd recommend in this case combining the definition and the declaration,
that avoids the problem with syntax altogether. Example:

template <typename X>
class foo
{
public:

  template <typename Y>
  Y bar(const Y& y, const X& x)
  {
    /* censored to protect the innocent */
  }
};

-- that's what I know to work with VC++6 and 7 in a situation like above.


> The problem here is that std::min and std::max do not seem to exist with
> VC6.  They are provided with VC .NET, but with VC6 they are renamed to
> _cpp_min and _cpp_max and then #defined to _MIN and _MAX.


On top of that, to compilicate things even further, if STLport 4.X.X is used
with VC6, the <algorithm> *does* supply std::min and std::max -- here's
cut'n'paste from header I wrote myself to work around the very same thing:


 #if defined(_MSC_VER) && (_MSC_VER <= 1200) && !defined(_STLPORT_VERSION)
 namespace std
 {
  template <typename T>
  inline T min(const T& a, const T& b)
  {
   return a < b ? a : b;
  }

  template <typename T>
  inline T max(const T& a, const T& b)
  {
   return a > b ? a : b;
  }
 } // namespace std
 #endif

.. normally I would recommend heavily against writing ANYTHING into the
std:: namespace, as it's reserved for Standard library, but.. in practise
that's what I do even against my very own recommendation. For EXR using own
entry point would propably work better..

exr::min, or exrmin, exrmax, or whatever works best for you guys..


> >  > 5.  Scoping error with variable declarations within 'for' loops,
> >  > resulting in multiple defines, required variables to be
> >  > declared outside
> >  > of the 'for' loop, once per function.
> >
> > I'm not too fond of the new scoping rule, but you can enable it in
> > VC++ 6.0 with "Disable language extensions", in the compiler settings.
> > It's off by default because it breaks existing code, in some cases
> > silently.
>
> This works nicely.  I will update the project files to include this
> setting.

In .cpp files that would be a possibility, but in headers, it would break
client code using the language extensions, there I'd just submit and write:

int i;
for ( i=0; i<20; ++i ) { ... }
...
for ( i=0; i<bla; ++i ) { ... }
...

Or use different variable name, whatever, but headers are a bit more
critical as I think they should function in more compilation environments as
for that clients don't usually have as much control over. Borland Builder
(atleast 5.X) doesn't even allow for-loops, switch statements or equivalent
in inline methods w/o emitting warning.. I don't have B5 at the moment, but
I recall issues like this can drive programmer scaling the walls pretty
quickly. =^)


Jukka





reply via email to

[Prev in Thread] Current Thread [Next in Thread]