MinGW not so good with exceptions?

D

Dave the Funkatron

Hey all,

I'm using MinGW as part of my toolchain in Eclipse, and I am trying to
figure out why I am getting a compiler error when I include the
<limits> header.

The command that eclipse is running is

g++ -IC:\Dave\School\common\cxx -IC:\Dave\School\common\third party
\packages\glut-3.7.6-bin\include -IC:\Dave\School\common\third party
\packages\pthreads-2005-03-08\Pre-built\include -O0 -g3 -Wall -c -
fmessage-length=0 -ogllib\test_gllib.o ..\gllib\test_gllib.cpp



The error I get is:

In file included from C:/Dave/School/common/cxx/math/math_utils.h:13,
from C:/Dave/School/common/cxx/gfx2d/color.h:9,
from C:/Dave/School/common/cxx/gllib/gl_light.h:
6, from ..\gllib\test_gllib.cpp:8:C:/mingw/bin/../lib/
gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/limits:290: error:
expected `;' before "throw"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292: error: expected `;' before "static"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292:22: macro "max" requires 2 arguments, but only 1 given



If I go and look at that code in MinGW's "limits" file, I see the
following struct, in which the the static min() function is the first
offending line of code:

template<typename _Tp>
struct numeric_limits : public __numeric_limits_base
{
/** The minimum finite value, or for floating types with
denormalization, the minimum positive normalized value. */
static _Tp min() throw() { return static_cast<_Tp>(0); }
/** The maximum finite value. */
static _Tp max() throw() { return static_cast<_Tp>(0); }
/** The @e machine @e epsilon: the difference between 1 and the
least
value greater than 1 that is representable. */
static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
/** The maximum rounding error measurement (see LIA-1). */
static _Tp round_error() throw() { return static_cast<_Tp>(0); }
/** The representation of positive infinity, if @c
has_infinity. */
static _Tp infinity() throw() { return static_cast<_Tp>(0); }
/** The representation of a quiet "Not a Number," if @c
has_quiet_NaN. */
static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
/** The representation of a signaling "Not a Number," if
@c has_signaling_NaN. */
static _Tp signaling_NaN() throw() { return
static_cast<_Tp>(0); }
/** The minimum positive denormalized value. For types where
@c has_denorm is false, this is the minimum positive
normalized
value. */
static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
};


I've never actually seen that throw() syntax before, as I've always
just had throw statements in the body of my code. At any rate, I
thought that GCC might be trying to compile without exceptions, so I
tried including the -fexceptions option to GCC, but that made no
difference. So, any ideas what might get it going?

Thanks.

Dave
 
G

Gerry Ford

Dave the Funkatron said:
Hey all,

I'm using MinGW as part of my toolchain in Eclipse, and I am trying to
figure out why I am getting a compiler error when I include the
<limits> header.

The command that eclipse is running is

g++ -IC:\Dave\School\common\cxx -IC:\Dave\School\common\third party
\packages\glut-3.7.6-bin\include -IC:\Dave\School\common\third party
\packages\pthreads-2005-03-08\Pre-built\include -O0 -g3 -Wall -c -
fmessage-length=0 -ogllib\test_gllib.o ..\gllib\test_gllib.cpp

Is this an entry for the latest "Command line gone wild" video?

The error I get is:

In file included from C:/Dave/School/common/cxx/math/math_utils.h:13,
from C:/Dave/School/common/cxx/gfx2d/color.h:9,
from C:/Dave/School/common/cxx/gllib/gl_light.h:
6, from ..\gllib\test_gllib.cpp:8:C:/mingw/bin/../lib/
gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/limits:290: error:
expected `;' before "throw"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292: error: expected `;' before "static"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292:22: macro "max" requires 2 arguments, but only 1 given



If I go and look at that code in MinGW's "limits" file, I see the
following struct, in which the the static min() function is the first
offending line of code:

template<typename _Tp>
struct numeric_limits : public __numeric_limits_base
{
/** The minimum finite value, or for floating types with
denormalization, the minimum positive normalized value. */
static _Tp min() throw() { return static_cast<_Tp>(0); }
/** The maximum finite value. */
static _Tp max() throw() { return static_cast<_Tp>(0); }
/** The @e machine @e epsilon: the difference between 1 and the
least
value greater than 1 that is representable. */
static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
/** The maximum rounding error measurement (see LIA-1). */
static _Tp round_error() throw() { return static_cast<_Tp>(0); }
/** The representation of positive infinity, if @c
has_infinity. */
static _Tp infinity() throw() { return static_cast<_Tp>(0); }
/** The representation of a quiet "Not a Number," if @c
has_quiet_NaN. */
static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
/** The representation of a signaling "Not a Number," if
@c has_signaling_NaN. */
static _Tp signaling_NaN() throw() { return
static_cast<_Tp>(0); }
/** The minimum positive denormalized value. For types where
@c has_denorm is false, this is the minimum positive
normalized
value. */
static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
};


I've never actually seen that throw() syntax before, as I've always
just had throw statements in the body of my code. At any rate, I
thought that GCC might be trying to compile without exceptions, so I
tried including the -fexceptions option to GCC, but that made no
difference. So, any ideas what might get it going?

Yeah, your folders have flourished like weeds. Trim them. Windows takes an
exception to you.
 
A

Alf P. Steinbach

* Dave the Funkatron:
Hey all,

I'm using MinGW as part of my toolchain in Eclipse, and I am trying to
figure out why I am getting a compiler error when I include the
<limits> header.

The command that eclipse is running is

g++ -IC:\Dave\School\common\cxx -IC:\Dave\School\common\third party
\packages\glut-3.7.6-bin\include -IC:\Dave\School\common\third party
\packages\pthreads-2005-03-08\Pre-built\include -O0 -g3 -Wall -c -
fmessage-length=0 -ogllib\test_gllib.o ..\gllib\test_gllib.cpp



The error I get is:

In file included from C:/Dave/School/common/cxx/math/math_utils.h:13,
from C:/Dave/School/common/cxx/gfx2d/color.h:9,
from C:/Dave/School/common/cxx/gllib/gl_light.h:
6, from ..\gllib\test_gllib.cpp:8:C:/mingw/bin/../lib/
gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/limits:290: error:
expected `;' before "throw"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292: error: expected `;' before "static"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292:22: macro "max" requires 2 arguments, but only 1 given

There shouldn't be any macro called "max".

If you have defined one yourself, don't.

If you're including some Windows headers, be sure to define NOMINMAX
first to avoid having that macro defined.


Cheers, & hth.,

- Alf
 
J

James Kanze

messagenews:20921642-3b06-4887-8f6f-78e9d492a701@u10g2000prn.googlegroups.com...

[...]
Is this an entry for the latest "Command line gone wild" video?

It's actually a lot shorter than one would expect. Compilers
are very complex beasts, which have to be configured very
exactly to do what one wants. My own makefiles generate command
lines that are considerably longer.

For commands generated by makefiles, who cares? For commands
you actually do enter at the command line, you define a couple
of shell variables, and use them. But just "g++ someProgram.cc"
(or "cl someProgram.cc" with VC++) will not normally give you
anything usable for anything other than a quick syntax test, if
that.
 
D

Dave the Funkatron

Is this an entry for the latest "Command line gone wild" video?












Yeah, your folders have flourished like weeds.  Trim them.  Windows takes an
exception to you.

--
Gerry Ford

"Er hat sich georgiert."  Der Spiegel, 2008, sich auf Chimpy Eins komma null
beziehend.- Hide quoted text -

- Show quoted text -

"Windows takes an exception to you" ?? Wow, you should watch your tone
on the newsgroups, or people might think you are a jerk. People like
me, for instance. This is especially true when you are giving
irrelevant advice. Like James said, that's actually a pretty short
command like. And, with the rise in storage capacity, paths are
getting longer. If you like, you can keeep your dir structures nice
and shallow, but I don't see why you care if mine are deep, or what
that has to do with the above syntax error.
 
D

Dave the Funkatron

* Dave the Funkatron:











There shouldn't be any macro called "max".

If you have defined one yourself, don't.

If you're including some Windows headers, be sure to define NOMINMAX
first to avoid having that macro defined.

Cheers, & hth.,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?- Hide quoted text -

- Show quoted text -

Thanks, Alf. That got me through that set of errors. I'm still not
building, but it looks more related to how Eclipse is setting up my
libs, so I'll take this to a different group.

Dave
 
V

Vaclav Haisman

Dave the Funkatron wrote, On 17.2.2008 10:27:
Hey all,

I'm using MinGW as part of my toolchain in Eclipse, and I am trying to
figure out why I am getting a compiler error when I include the
<limits> header.

The command that eclipse is running is

g++ -IC:\Dave\School\common\cxx -IC:\Dave\School\common\third party
\packages\glut-3.7.6-bin\include -IC:\Dave\School\common\third party
\packages\pthreads-2005-03-08\Pre-built\include -O0 -g3 -Wall -c -
fmessage-length=0 -ogllib\test_gllib.o ..\gllib\test_gllib.cpp



The error I get is:

In file included from C:/Dave/School/common/cxx/math/math_utils.h:13,
from C:/Dave/School/common/cxx/gfx2d/color.h:9,
from C:/Dave/School/common/cxx/gllib/gl_light.h:
6, from ..\gllib\test_gllib.cpp:8:C:/mingw/bin/../lib/
gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/limits:290: error:
expected `;' before "throw"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292: error: expected `;' before "static"
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/
limits:292:22: macro "max" requires 2 arguments, but only 1 given
That's problem with windows.h header. It or one of headers it includes
defines macros min() and max() and those expand inside the C++ headers and
result in the error.

You should be able to fix it by making sure windows.h is included only after
any standard C++ header. Or you can #undef min and #undef max before any
standard C++ header. Or you can define NOMINMAX symbol before including
windows.h so that it does not define the two macros.
 
G

Gerry Ford

messagenews:20921642-3b06-4887-8f6f-78e9d492a701@u10g2000prn.googlegroups.com...

Yeah, your folders have flourished like weeds. Trim them. Windows takes an
exception to you.


"Windows takes an exception to you" ?? Wow, you should watch your tone
on the newsgroups, or people might think you are a jerk. People like
me, for instance. This is especially true when you are giving
irrelevant advice. Like James said, that's actually a pretty short
command like. And, with the rise in storage capacity, paths are
getting longer. If you like, you can keeep your dir structures nice
and shallow, but I don't see why you care if mine are deep, or what
that has to do with the above syntax error.
--->My tone was too sharp, given that we don't know each other. I
apologize.

That said, I think you need to trim your folders. The following screenshot
shows mingw with a recent release:
http://zaxfuuq.net/c++2.jpg

There's nothing stopping a person from lopping off the directory extremities
and putting it closer to the bin. Heck I've even put gcc right off of C: so
as not to have "Documents and Settings" or "Program Files" gumming up a dos
line. This:is unreadable and unwieldy.
 
J

James Kanze

This:> > C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4..5/

is unreadable and unwieldy.

Which is totally irrelevant if you never see it nor write it
yourself.

In my own makefiles, I do expect the user to have set his path
so that the compiler is found by simply "g++". Not because it
makes command lines shorter however, but because it allows
changing compiler versions simply by changing a few shell
variables. A typical compiler invocation will still be well
over a thousand characters, and a link using several libraries
might be considerably more. Making a library is even worse,
since the makefile generates the absolute filename for every
file in the library (and the absolute filenames can easily
be around 80 characters or more each).

FWIW: a typical filename might be something like:
/home/team02/jakan/generated/i80x86-linux-gcc/component/
PrototypeFile/ProtoFileAsDataStruct.o
I don't see much that can be trimmed there.
 
G

Gerry Ford

This:> >
C:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/

is unreadable and unwieldy.

Which is totally irrelevant if you never see it nor write it
yourself.

In my own makefiles, I do expect the user to have set his path
so that the compiler is found by simply "g++". Not because it
makes command lines shorter however, but because it allows
changing compiler versions simply by changing a few shell
variables. A typical compiler invocation will still be well
over a thousand characters, and a link using several libraries
might be considerably more. Making a library is even worse,
since the makefile generates the absolute filename for every
file in the library (and the absolute filenames can easily
be around 80 characters or more each).

FWIW: a typical filename might be something like:
/home/team02/jakan/generated/i80x86-linux-gcc/component/
PrototypeFile/ProtoFileAsDataStruct.o
I don't see much that can be trimmed there.

--->But what you show is maybe six folders deep. The Funkatron's folders
were 14 deep on that line only. I think there's a design flaw to have the
top and bottom directories more than six folders deep. Computers will do
what they're told. Humans don't know where things are.

I've been dabbling with mingw stuff recently and find that my life gets a
lot better when I rearrange what comes as a package to put it close to my
source files. Another thing I do is put a shortcut to a dos window in
whatever folder I'm to find source files.
 
J

James Kanze

"James Kanze" <[email protected]> wrote in message

[...]
But what you show is maybe six folders deep. The Funkatron's folders
were 14 deep on that line only.

Actually, it was only 4 deep. Less than mine, in fact.
(Historically, I had two additional levels, because it was
i80x86/linux/gcc, rather than i80x86-linux-gcc; one of the
systems I was using at the time wouldn't allow more than 8
characters in a directory name.)
I think there's a design flaw to have the top and bottom
directories more than six folders deep.

Why? It's called a hierarchial directory structure for a
reason. For example, /home/team02/jakan is simple $HOME to me;
it could have 20 levels, and it wouldn't change anything in the
way I work. I never look under it. And the people who are
concerned with what's under it never really look further down.
I've got header files at least 11 levels from the root, but it
doesn't bother me---when I'm concerned with them, I'm in a
sub-directory which is only about two or three levels lower, and
when I'm further down, they don't interest me.
Computers will do what they're told. Humans don't know where
things are.

Which is why you need a hierarchial structure. So you don't
have to be concerned with everything at once.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top