Hi,

I've mostly only coded in stl c++ before despite using Visual studio
for a long time for C#. So this is a new one on me.

In stl c++ I could do the following

std::numeric_limits<float>::max()

and thus get the maximum value a float could hold on a machine. This
is a bit non-critical at the moment, as I can just SET the value since
I'm only developing for one platform, but here's my problem.

In VS2008, it sees that as an implementation of _max(int a, int b),
and won't compile.

I'm clearly missing something. I'm including <limits>, is there some
other include that I'm missing?

Re: Easy question on numeric limits by Victor

Victor
Thu Oct 09 09:03:40 CDT 2008

Scoots wrote:
> I've mostly only coded in stl c++ before despite using Visual studio
> for a long time for C#. So this is a new one on me.
>
> In stl c++ I could do the following
>
> std::numeric_limits<float>::max()
>
> and thus get the maximum value a float could hold on a machine. This
> is a bit non-critical at the moment, as I can just SET the value since
> I'm only developing for one platform, but here's my problem.
>
> In VS2008, it sees that as an implementation of _max(int a, int b),
> and won't compile.
>
> I'm clearly missing something. I'm including <limits>, is there some
> other include that I'm missing?

No, it's the macro 'max' from <windows.h> that's probably interfering
with your work. Try

#define NOMINMAX

at the top of your source code.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Re: Easy question on numeric limits by Scoots

Scoots
Thu Oct 09 09:12:16 CDT 2008

On Oct 9, 10:03=A0am, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> No, it's the macro 'max' from <windows.h> that's probably interfering
> with your work. =A0Try
>
> =A0 =A0#define NOMINMAX
>
> at the top of your source code.
>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask- Hide quoted tex=
t -
>
> - Show quoted text -

Yup, that did it! No wonder I'd never run into it before, and you are
quite right in that windows.h was included in the stdafx.h.

Thanks Victor,
~Scoots