Using "numeric_limits<double>::min()" in MFC application

Discussion in 'C++' started by Jalal, May 6, 2004.

  1. Jalal

    Jalal Guest

    I am trying to use numeric_limits<double>::min() in an MFC application
    in Microsoft Visual C++.NET 2003. I am having some difficulties here.
    The following are the parts of a simple program I wrote and
    corresponding error massages. I am confused here. Similar codes work
    fine in Win32 Console Project. Can you please help me to resolve
    this? Thank you for your helps.

    Best Regards,

    Jalal



    Code
    -------------------------------
    // Created by Microsoft Visual C++.NET
    #include "stdafx.h"
    #include "test.h"
    #include "testDlg.h"
    #include ".\testdlg.h"

    // I have added to use numeric_limits
    #include <limits>
    using namespace std;


    void CtestDlg::OnBnClickedSubmit()
    {
    double y;

    // TODO: Add your control notification handler code here
    UpdateData(TRUE);

    y = numeric_limits<double>::min();

    // Writing y in dialog box
    x.Format("%.10f", double(y));

    UpdateData(FALSE);
    }


    Error massage:
    -----------------------
    warning C4003: not enough actual parameters for macro 'min'
    error C2589: '(' : illegal token on right side of '::'
    error C2059: syntax error : '::'
    Jalal, May 6, 2004
    #1
    1. Advertising

  2. Jalal

    Pete Becker Guest

    Jalal wrote:
    >
    > warning C4003: not enough actual parameters for macro 'min'
    > error C2589: '(' : illegal token on right side of '::'
    > error C2059: syntax error : '::'


    The windows headers do you the favor of providing macros named 'min' and
    'max' that can screw up your code. To get rid of 'em, add

    #define NOMINMAX

    to your stdafx.h file, before any #include directives.

    --

    Pete Becker
    Dinkumware, Ltd. (http://www.dinkumware.com)
    Pete Becker, May 6, 2004
    #2
    1. Advertising

  3. * (Jalal) schriebt:
    > I am trying to use numeric_limits<double>::min()


    Yes?


    > in an MFC application in Microsoft Visual C++.NET 2003.


    That's off-topic here, but you'll get answers to such questions in
    e.g. [comp.os.ms-windows.programmer.win32] (I might even answer it
    there myself ;-) ), or in a Microsoft newsgroup.



    > I am having some difficulties here.
    > The following are the parts of a simple program I wrote and
    > corresponding error massages. I am confused here. Similar codes work
    > fine in Win32 Console Project. Can you please help me to resolve
    > this? Thank you for your helps.


    To top it off you have not included the _relevant_ parts of your program.
    Please do that when reposting your question in e.g. the group mentioned
    above. Might also be a good idea to state that the question was earlier
    posted in [comp.lang.c++] but off-topic there.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, May 6, 2004
    #3
  4. Jalal

    Rolf Magnus Guest

    Alf P. Steinbach wrote:

    > * (Jalal) schriebt:
    >> I am trying to use numeric_limits<double>::min()

    >
    > Yes?


    What makes you doubt that?

    >> in an MFC application in Microsoft Visual C++.NET 2003.

    >
    > That's off-topic here, but you'll get answers to such questions in
    > e.g. [comp.os.ms-windows.programmer.win32] (I might even answer it
    > there myself ;-) ), or in a Microsoft newsgroup.


    The question isn't actually about MFC, though the problem itself seems
    to be related to the windows platform. However, the OP probably didn't
    know that. He just got an error message about
    numeric_limits<double>::max(), so he wanted to know what he's doing
    wrong.

    >> I am having some difficulties here.
    >> The following are the parts of a simple program I wrote and
    >> corresponding error massages. I am confused here. Similar codes
    >> work
    >> fine in Win32 Console Project. Can you please help me to resolve
    >> this? Thank you for your helps.

    >
    > To top it off you have not included the _relevant_ parts of your
    > program.


    He hasn't? What would be missing?

    > Please do that when reposting your question in e.g. the group
    > mentioned above. Might also be a good idea to state that the question
    > was earlier posted in [comp.lang.c++] but off-topic there.


    The question wasn't, even if the answer might be.
    Rolf Magnus, May 6, 2004
    #4
  5. * Rolf Magnus <> schriebt:
    > Alf P. Steinbach wrote:
    >
    > > * (Jalal) schriebt:
    > >> I am trying to use numeric_limits<double>::min()

    > >
    > > Yes?

    >
    > What makes you doubt that?


    Why do you think I doubt what?


    > >> in an MFC application in Microsoft Visual C++.NET 2003.

    > >
    > > That's off-topic here, but you'll get answers to such questions in
    > > e.g. [comp.os.ms-windows.programmer.win32] (I might even answer it
    > > there myself ;-) ), or in a Microsoft newsgroup.

    >
    > The question isn't actually about MFC, though the problem itself seems
    > to be related to the windows platform.


    It is about one particular vendor's header files for the Windows platform.


    > However, the OP probably didn't
    > know that. He just got an error message about
    > numeric_limits<double>::max(), so he wanted to know what he's doing
    > wrong.


    One thing he or she did wrong was to not try it out in standard C++ before
    asking in a standard C++ Usenet group.


    > >> I am having some difficulties here.
    > >> The following are the parts of a simple program I wrote and
    > >> corresponding error massages. I am confused here. Similar codes
    > >> work
    > >> fine in Win32 Console Project. Can you please help me to resolve
    > >> this? Thank you for your helps.

    > >
    > > To top it off you have not included the _relevant_ parts of your
    > > program.

    >
    > He hasn't? What would be missing?


    What was missing was the include file where the vendor-specific header
    files were erronously included for C++, namely [stdafx.h].


    > > Please do that when reposting your question in e.g. the group
    > > mentioned above. Might also be a good idea to state that the question
    > > was earlier posted in [comp.lang.c++] but off-topic there.

    >
    > The question wasn't, even if the answer might be.


    Both the question and the answer were off-topic. The question because it
    concerned use of one particular vendor's header files on one particular
    platform, as could easily be ascertained by trying standard C++. The answer
    for the same reason, but then it's toss-of-the-coin whether to give a very
    short "satisfying" answer (short-term) or point to a more appropriate group.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, May 6, 2004
    #5
  6. Jalal

    P.J. Plauger Guest

    "Alf P. Steinbach" <> wrote in message
    news:...

    > Both the question and the answer were off-topic. The question because it
    > concerned use of one particular vendor's header files on one particular
    > platform, as could easily be ascertained by trying standard C++. The

    answer
    > for the same reason, but then it's toss-of-the-coin whether to give a very
    > short "satisfying" answer (short-term) or point to a more appropriate

    group.

    Gosh. And I just tried compiling a simple program with gcc.
    The headers look reasonably conforming, and yet I get
    this diagnostic from the linker that sqrt is undefined.
    Had I known that I failed to write the -lm flag on the
    compiler command line, I would have known *not* to ask
    for help from this newsgroup (where many contributors
    happen to know the answer), but to go to a gcc specific
    newsgroup instead. Where's prescience when you really
    need it?

    The C++ Standard is a worthless document without real
    live implementations of the language it describes.
    Sadly, there are no standards for the kind of gotchas
    different implementations inflict on us. If only there
    were a newsgroup that understood this, or at least had
    less zealous Topic Police.

    P.J. Plauger
    Dinkumware, Ltd.
    http://www.dinkumware.com
    P.J. Plauger, May 6, 2004
    #6
  7. * "P.J. Plauger" <> schriebt:
    > "Alf P. Steinbach" <> wrote in message
    > news:...
    >
    > > Both the question and the answer were off-topic. The question because it
    > > concerned use of one particular vendor's header files on one particular
    > > platform, as could easily be ascertained by trying standard C++. The

    > answer
    > > for the same reason, but then it's toss-of-the-coin whether to give a very
    > > short "satisfying" answer (short-term) or point to a more appropriate

    > group.
    >
    > Gosh. And I just tried compiling a simple program with gcc.
    > The headers look reasonably conforming, and yet I get
    > this diagnostic from the linker that sqrt is undefined.
    > Had I known that I failed to write the -lm flag on the
    > compiler command line, I would have known *not* to ask
    > for help from this newsgroup (where many contributors
    > happen to know the answer), but to go to a gcc specific
    > newsgroup instead.


    Well you're so experienced by now, having written all these libraries and
    whatnot, that you know that a linker issue is pure tool usage and is
    off-topic in this group. The same goes for how to include <windows.h>
    properly for C++, or how to use MS Visual Studio. This is in the FAQ.

    I don't understand why the heck you're jumping in here, because you sure
    as h... do know all this, and would never be confused by a linker issue.


    >Where's prescience when you really need it?


    Indeed, one cannot know in advance the details of why an error occurs.

    But one can know that it is to do with linking (pure tool usage).

    Or that is to do with #include of Microsoft's <windows.h> (pure MS issue).




    > The C++ Standard is a worthless document without real
    > live implementations of the language it describes.
    > Sadly, there are no standards for the kind of gotchas
    > different implementations inflict on us. If only there
    > were a newsgroup that understood this, or at least had
    > less zealous Topic Police.


    I agree with that. Such groups exist. E.g., [no.it.programmering.c++],
    which is a Norwegian group where English threads are supported -- sometimes
    frequented by Bjarne, and perhaps in the future also you?

    Also, perhaps what's regarded as on-topic here should be loosened up a bit.

    I've argued for that before, and will probably also in the future...

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, May 6, 2004
    #7
  8. Jalal

    Julie Guest

    "Alf P. Steinbach" wrote:
    [snip]
    > Also, perhaps what's regarded as on-topic here should be loosened up a bit.


    Funny thing is that since this newsgroup doesn't have a charter, there really
    isn't a notion of on or off topic here...

    The FAQ ain't it, either.

    First things first, let's get a charter for the newsgroup.
    Julie, May 6, 2004
    #8
  9. Julie wrote:

    > Alf P. Steinbach wrote:
    > [snip]
    >
    >>Also, perhaps what's regarded as on-topic here should be loosened up a bit.

    >
    > Funny thing is that since this newsgroup doesn't have a charter,
    > there really isn't a notion of on or off topic here...


    There certainly *is* strong opinion
    about what is on and off topic in the comp.lang.c++ newsgroup.
    Whether there is consensus or not is independent
    of whether there is a charter or not.

    >
    > The FAQ ain't it, either.
    >
    > First things first, let's get a charter for the newsgroup.


    A charter won't help build consensus.
    A charter won't help enforce rules.
    A charter probably won't even help end discussion
    about what is on or off topic in this newsgroup.

    What helps is if you ignore off-topic articles.
    If a subject is off-topic in the comp.lang.c++ newsgroup,
    it is usually sufficient to simply mention that fact
    to alert unwary subscribers who might otherwise respond.

    Almost all off-topic articles are posted by regular subscribers
    as an off-topic digression from a legitimate thread.
    Only a tiny fraction are posted by new subscribers.

    The comp.lang.c++ has a higher signal-to-noise ratio
    than newsgroups that have a charter.
    Let's not screw that up.
    E. Robert Tisdale, May 7, 2004
    #9
  10. * Julie <> schriebt:
    > "Alf P. Steinbach" wrote:
    > [snip]
    > > Also, perhaps what's regarded as on-topic here should be loosened up a bit.

    >
    > Funny thing is that since this newsgroup doesn't have a charter, there really
    > isn't a notion of on or off topic here...
    >
    > The FAQ ain't it, either.
    >
    > First things first, let's get a charter for the newsgroup.


    Well, I'm not sure of the technicalities of retrofitting a charter, but in
    principle I agree with you -- the infamous "someone" should do this!

    The FAQ as well as the monthly posting should of course include the charter,
    when and if it gets written and passes voting (caveat: procedure for that?).

    A good place to start might be the [comp.lang.c++.moderated] charter, e.g. at
    <url:
    ftp://ftp.isc.org/usenet/news.announce.newgroups/comp/comp.lang.c++.moderated>:

    <CLC++M CHARTER>
    comp.lang.c++.moderated is a moderated news group for discussion of common
    C++ programming issues. Welcomed topics of discussion will include any topic
    directly related to the C++ programming language. The moderators will decide
    which posts are of general interest to the worldwide C++ community. The
    moderators are free to reject any post which is deemed to be system-specific,
    covered by the comp.lang.c++ FAQ(s), and/or more appropriate to another
    Usenet discussion group. The following is a short list of posts which
    will be considered off-topic by the moderators.

    - System-specific problems which are better addressed in existing
    system-specific newsgroups may be considered off-topic. (Here we
    are using the term "system-specific" in reference to a particular
    computer system configuration.)
    - Questions answered in the comp.lang.c++ FAQ(s) will be considered
    off-topic.
    - Obvious homework problems and trivial questions that can be answered by
    quick inspection of any C++ text may be considered off-topic.
    - Very broad questions which could equally apply to any computer programming
    language may be considered off-topic.
    - Advocacy and "flame wars" about C++ will be considered off-topic.
    - Advertising shall be considered off-topic.
    - C++ product announcements shall be at the discretion of the
    moderators.

    Overall, the moderators shall lean towards accepting posts and the free
    exchange of ideas and general discussion of C++ issues.
    </CLC++M CHARTER>

    What's a bit lacking here, in my opinion, is topicality of library-specific
    problems. A library may be system independent (such as Boost), or very widely
    used. But there is a difference discussing the use of e.g. boost::shared_ptr
    for pimpl idiom, and on the other hand "how do I implement Tiny Basic using
    Boost Spirit?" -- which I'd regard as off-topic no matter Boost or not. In
    short there must be some general C++ relevance, not just a C++ association.
    The charter says any topic directly related to the C++ language is welcomed,
    but it doesn't say any topic only vaguely associated to C++ is unwelcome.

    Also, there is the question of actually using C++ for those tasks the language
    is intended for.

    For example, currently the use of C++ to provide bindings for other languages,
    such as Java JNI, is off-topic in just about any group except
    [comp.programming], but I think such actual practice should be on-topic here.

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, May 7, 2004
    #10
  11. Jalal

    Julie Guest

    "E. Robert Tisdale" wrote:
    >
    > Julie wrote:
    >
    > > Alf P. Steinbach wrote:
    > > [snip]
    > >
    > >>Also, perhaps what's regarded as on-topic here should be loosened up a bit.

    > >
    > > Funny thing is that since this newsgroup doesn't have a charter,
    > > there really isn't a notion of on or off topic here...

    >
    > There certainly *is* strong opinion
    > about what is on and off topic in the comp.lang.c++ newsgroup.
    > Whether there is consensus or not is independent
    > of whether there is a charter or not.
    >
    > >
    > > The FAQ ain't it, either.
    > >
    > > First things first, let's get a charter for the newsgroup.

    >
    > A charter won't help build consensus.
    > A charter won't help enforce rules.
    > A charter probably won't even help end discussion
    > about what is on or off topic in this newsgroup.


    All true, however it doesn't change the fact that a charter should be the first
    order of business if better defining newsgroup topicality is needed.

    > The comp.lang.c++ has a higher signal-to-noise ratio
    > than newsgroups that have a charter.
    > Let's not screw that up.


    Are you concluding that necessarily having a charter decreases signal to noise?
    Julie, May 7, 2004
    #11
  12. "Julie" <> wrote in message
    news:...
    > "Alf P. Steinbach" wrote:
    > [snip]
    > > Also, perhaps what's regarded as on-topic here should be loosened up a

    bit.
    >
    > Funny thing is that since this newsgroup doesn't have a charter, there

    really
    > isn't a notion of on or off topic here...
    >
    > The FAQ ain't it, either.
    >
    > First things first, let's get a charter for the newsgroup.




    But Usenet is still governed by the old days spirit of freedom. That means
    that when you think something does not fit to be discussed here, you notify
    the user to find a more appropriate newsgroup.






    Regards,

    Ioannis Vranos
    Ioannis Vranos, May 7, 2004
    #12
  13. "Julie" <> wrote in message
    news:...
    >
    > All true, however it doesn't change the fact that a charter should be the

    first
    > order of business if better defining newsgroup topicality is needed.



    The topicality is well known. ISO C++.






    Regards,

    Ioannis Vranos
    Ioannis Vranos, May 7, 2004
    #13
  14. Jalal

    Jalal Guest

    Dear Pete:

    I have implemented what you have suggested. My program is now
    working. Thank you for your helps.

    Best Regards,

    Jalal


    Pete Becker <> wrote in message news:<>...
    > Jalal wrote:
    > >
    > > warning C4003: not enough actual parameters for macro 'min'
    > > error C2589: '(' : illegal token on right side of '::'
    > > error C2059: syntax error : '::'

    >
    > The windows headers do you the favor of providing macros named 'min' and
    > 'max' that can screw up your code. To get rid of 'em, add
    >
    > #define NOMINMAX
    >
    > to your stdafx.h file, before any #include directives.
    Jalal, May 7, 2004
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott McPhillips
    Replies:
    0
    Views:
    378
    Scott McPhillips
    Jul 5, 2003
  2. ds
    Replies:
    1
    Views:
    1,896
    Victor Bazarov
    Dec 23, 2004
  3. ringos75
    Replies:
    0
    Views:
    955
    ringos75
    Apr 14, 2005
  4. yopwojtek

    Derive from MFC DLL to MFC APP

    yopwojtek, Aug 6, 2005, in forum: C++
    Replies:
    1
    Views:
    387
    Alf P. Steinbach
    Aug 6, 2005
  5. Replies:
    1
    Views:
    522
    John Ratliff
    Aug 12, 2005
Loading...

Share This Page