On Monday 27 February 2006 04:44, Jon S. Berndt wrote:
> > Stupid me. I worded the problem incorrectly. Obviously, the
> > problem is with
> > a compile of the FlightGear test program, with the definition or use of
> > "min".
>
> Here's the offensive code in /usr/local/include/simgear/math/SGMisc.hxx
>
> === start ===
>
> #ifndef SGMisc_H
> #define SGMisc_H
>
> #include <cmath>
>
> template<typename T>
> class SGMisc {
> public:
>   static T pi() { return T(3.1415926535897932384626433832795029L); }
>   static T min(const T& a, const T& b)
>
> === end ===
>
> The last line, above, is the culprit. As before, the errors are:
>
> SGMisc.hxx:28: error: expected unqualified-id before "const"
> SGMisc.hxx:28: error: expected `)' before "const"
> SGMisc.hxx:28: error: expected `)' before "const"
>
> The rest of the errors (lots of them), likewise involve "min".
>
> Jon
>
> P.S. What is the test-up application, anyhow? Can we avoid compiling that?
> Or, is it needed?

Yes it is needed and used.

It is a handy and typesafe way to program a min or max function.
You know exactly what type the input arguments are and which the output 
arguments are.

What you can do when you want a float max is

SFMisc<float>::max(b, a)

You don't get ambiguities and you dont get whatever min/max is defined in the 
global namespace you dont know about which types are used when it is really 
defined.

What brakes, but that brakes anyway if you do includes in the wrong order, is 
that a prevously defined min/max macro will disturb the 
declaration/implementation of the SGMisc min/max as it would disturb that for 
every other min/max declaration/implementation like the std::min/std::max 
functions for example too.

I bet that you defined such a macro and past that include SGMath.h

Greetings

      Mathias



-- 
Mathias Fröhlich, email: [EMAIL PROTECTED]


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to