473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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 : '::'
Jul 22 '05 #1
13 3255
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)
Jul 22 '05 #2
* m.*****@worldnet.att.net (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?
Jul 22 '05 #3
Alf P. Steinbach wrote:
* m.*****@worldnet.att.net (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.

Jul 22 '05 #4
* Rolf Magnus <ra******@t-online.de> schriebt:
Alf P. Steinbach wrote:
* m.*****@worldnet.att.net (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?
Jul 22 '05 #5
"Alf P. Steinbach" <al***@start.no> wrote in message
news:40*****************@news.individual.net...
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
Jul 22 '05 #6
* "P.J. Plauger" <pj*@dinkumware.com> schriebt:
"Alf P. Steinbach" <al***@start.no> wrote in message
news:40*****************@news.individual.net...
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?
Jul 22 '05 #7
"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.
Jul 22 '05 #8
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.

Jul 22 '05 #9
* Julie <ju***@nospam.com> 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?
Jul 22 '05 #10
"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?
Jul 22 '05 #11
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...
"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

Jul 22 '05 #12
"Julie" <ju***@nospam.com> wrote in message
news:40***************@nospam.com...

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

Jul 22 '05 #13
Dear Pete:

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

Best Regards,

Jalal
Pete Becker <pe********@acm.org> wrote in message news:<40***************@acm.org>...
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.

Jul 22 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Woo | last post by:
How do I upload a file to an ASP page using a C# application(client). The client side is c# application which takes the filename. and the server side is written in asp. John *** Sent via...
2
by: Alexander | last post by:
I use same assembly in Application and in Web. How can i determine - assembly using in Application or in Web? (Some feautures i cant use in Web)
3
by: nkunapa | last post by:
Hi: I am looking for any ideas/comments/suggestions on how a Windows Service kind of functionality can be acheived from a web application which which will run under IIS or for that matter any...
0
by: vasanth | last post by:
I have written an application to record sound from soundcard using directx 8. But when i start an audio chat using Google Talk and when i run this application, it gives an automation error. When...
7
by: SparkPlug | last post by:
Does anyone know why I might be getting an XmlSchemaException in App.config configured as below to use the UIP Application Block? I get the following error for every element, sub-element and...
3
by: Naveen | last post by:
How can we keep track of how many active users are using the application.
0
by: suedasszyy | last post by:
Haiiii.... i'm new for VB.net. can someone help me to solve those question? is it possible to draw a graph such as Sin graph using console application? if not, how can i draw a graph...
5
by: Claudia Fong | last post by:
Hi, I'm using console application to connect to a db and I managed to use the SELECT statement to display records in my DB but I also need to UPDATE some fields in my table but after I run the...
3
by: ramesh.nrk | last post by:
Hi, Is there any way to read the cookies which are in local machine? Can we create cookies using windows Application in the local machine? I am developing a windows application which needs...
3
by: Oriane | last post by:
Hi there, I would like to open my Asp.Net project as a "Web Application" rather than as a "Web Site" in Visual Studio. But the thing is that I use the System.Web.Profile and the auto-generated...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.