VC++ problem - head files - "except" and "process"

VC++ problem - head files - "except" and "process"

Post by wan cja » Sat, 17 Nov 2001 10:22:13



Hi,

I have a problem when using VC++, the following code I tested on
"borland c++ 5.02" was OK, but got Compiling error on VC++. The
problem come from the head files ("except" and "process"). If VC++
don't have these head file, how to use "xalloc" and "EXIT_FAILURE"?

Thanks for help.

#include <except>
#include <process>
#include <iostream>
using namespace std;

...
try{
   ...
   myarray = new int[100];
   ...

Quote:}catch(xalloc){

   exit(EXIT_FAILURE);
Quote:}

...
 
 
 

VC++ problem - head files - "except" and "process"

Post by Neil Butterwort » Sat, 17 Nov 2001 10:32:27



Quote:> Hi,

> I have a problem when using VC++, the following code I tested on
> "borland c++ 5.02" was OK, but got Compiling error on VC++. The
> problem come from the head files ("except" and "process"). If VC++
> don't have these head file, how to use "xalloc" and "EXIT_FAILURE"?

> Thanks for help.

> #include <except>

The standard C++ header for exceptions is <exception>

Quote:> #include <process>

There is no standard C++ header (or support) for processes.

Quote:> #include <iostream>
> using namespace std;

> ...
> try{
>    ...
>    myarray = new int[100];
>    ...
> }catch(xalloc){
>    exit(EXIT_FAILURE);
> }

The headers you are using appear to be Borland inventions. Please post
further questions regarding them to one of the Borland support news groups
on the newsgroups.borland.com news server - these questions are off-topic in
comp.lang.c++.

EXIT_FAILURE should be defined in <cstdlib>

There is no such Standard C++ exception as xalloc.

NeilB

 
 
 

VC++ problem - head files - "except" and "process"

Post by Kaz Kylhe » Sat, 17 Nov 2001 10:44:40



>Hi,

>I have a problem when using VC++, the following code I tested on
>"borland c++ 5.02" was OK, but got Compiling error on VC++. The
>problem come from the head files ("except" and "process"). If VC++
>don't have these head file, how to use "xalloc" and "EXIT_FAILURE"?

>Thanks for help.

>#include <except>
>#include <process>
>#include <iostream>
>using namespace std;

The first two of these are not standard headers. The symbol EXIT_FAILURE
comes from ANSI C and is defined in <stdlib.h>. In C++, you can use
<cstdlib> instead.

Quote:>...
>try{
>   ...
>   myarray = new int[100];
>   ...
>}catch(xalloc){
>   exit(EXIT_FAILURE);
>}
>...

The standard C++ exception type for a memory allocation failure is
std::bad_alloc; it is declared in the header <new>.
 
 
 

VC++ problem - head files - "except" and "process"

Post by Pete Becke » Sun, 18 Nov 2001 09:43:51



> There is no such Standard C++ exception as xalloc.

However, there was at one time, although its name changed to bad_alloc
several years before the standard was finished. In the meantime, though,
compilers shipped with xalloc in their libraries.

--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)

 
 
 

VC++ problem - head files - "except" and "process"

Post by wan cja » Mon, 19 Nov 2001 16:05:28


Quote:> The headers you are using appear to be Borland inventions. Please post
> further questions regarding them to one of the Borland support news groups
> on the newsgroups.borland.com news server - these questions are off-topic in
> comp.lang.c++.

off-topic? I thought any c++ question can be sent in
comp.lang.c++...not true? Anyway, my current interest is VC++, not
borland, so I better stay with comp.lang.c++.-)))
 
 
 

VC++ problem - head files - "except" and "process"

Post by wan cja » Mon, 19 Nov 2001 16:14:27




> > There is no such Standard C++ exception as xalloc.

> However, there was at one time, although its name changed to bad_alloc
> several years before the standard was finished. In the meantime, though,
> compilers shipped with xalloc in their libraries.

I don't like to install both VC++ and Borland on my computer, so
Borland has been take off at the moment, I am wondering if bad_alloc
is supported in Borland now?
 
 
 

VC++ problem - head files - "except" and "process"

Post by wan cja » Mon, 19 Nov 2001 16:28:09


Quote:> >#include <except>
> >#include <process>
> >#include <iostream>
> >using namespace std;

> The first two of these are not standard headers. The symbol EXIT_FAILURE
> comes from ANSI C and is defined in <stdlib.h>. In C++, you can use
> <cstdlib> instead.

I have just checked <cstdlib> file, it only defined <stdlib.h>, why
can't we use <stdlib> instead of <cstdlib>?
Quote:

> >...
> >try{
> >   ...
> >   myarray = new int[100];
> >   ...
> >}catch(xalloc){
>  exit(EXIT_FAILURE);
> >}
> >...

> The standard C++ exception type for a memory allocation failure is
> std::bad_alloc; it is declared in the header <new>.

You have supplied the complete solution to my 2 questions. Thanks. One
more question, when I used <exception> to replace <new>, it is also
works, but I can't find bad_alloc in <exception> head file, why?
 
 
 

VC++ problem - head files - "except" and "process"

Post by Neil Butterwort » Tue, 20 Nov 2001 01:32:40



Quote:> > The headers you are using appear to be Borland inventions. Please post
> > further questions regarding them to one of the Borland support news
groups
> > on the newsgroups.borland.com news server - these questions are
off-topic in
> > comp.lang.c++.
> off-topic? I thought any c++ question can be sent in
> comp.lang.c++...not true?

Questions about stansard C++, yes. Questions about a specific
implementation, no.

Quote:> Anyway, my current interest is VC++, not
> borland, so I better stay with comp.lang.c++.-)))

I assume that was a joke. If not, prepare for a rough ride.

NeilB

 
 
 

VC++ problem - head files - "except" and "process"

Post by wan cja » Tue, 20 Nov 2001 10:37:35





> > > The headers you are using appear to be Borland inventions. Please post
> > > further questions regarding them to one of the Borland support news
>  groups
> > > on the newsgroups.borland.com news server - these questions are
>  off-topic in
> > > comp.lang.c++.
> > off-topic? I thought any c++ question can be sent in
> > comp.lang.c++...not true?

> Questions about stansard C++, yes. Questions about a specific
> implementation, no.

> > Anyway, my current interest is VC++, not
> > borland, so I better stay with comp.lang.c++.-)))

> I assume that was a joke. If not, prepare for a rough ride.

> NeilB

Interested in VC++ - not true! Actually I have to use VC++ compiler
with one of the application in my current job.

Stay with comp.lang.c++ - hehe, you may assume this is a serious joke,
I will stay with this group as long as my working life since I can't
find a better c++ group. Please forgive me if I ask any stupid
question as I am newbie of this group and c++. Sometimes I just can't
judge myself which question is unfitable for this group. Thanks in
Advance for not kicking out of this group.

 
 
 

VC++ problem - head files - "except" and "process"

Post by Micah Cowa » Wed, 21 Nov 2001 04:36:16



> > >#include <except>
> > >#include <process>
> > >#include <iostream>
> > >using namespace std;

> > The first two of these are not standard headers. The symbol EXIT_FAILURE
> > comes from ANSI C and is defined in <stdlib.h>. In C++, you can use
> > <cstdlib> instead.
> I have just checked <cstdlib> file, it only defined <stdlib.h>, why
> can't we use <stdlib> instead of <cstdlib>?

> > >...
> > >try{
> > >   ...
> > >   myarray = new int[100];
> > >   ...
> > >}catch(xalloc){
> >  exit(EXIT_FAILURE);
> > >}
> > >...

> > The standard C++ exception type for a memory allocation failure is
> > std::bad_alloc; it is declared in the header <new>.
> You have supplied the complete solution to my 2 questions. Thanks. One
> more question, when I used <exception> to replace <new>, it is also
> works, but I can't find bad_alloc in <exception> head file, why?

Not all exceptions are found in <exception>.  bad_alloc is only found
in <new>, others may be found in <typeinfo>, a few are in <exception>,
and several are in <stdexcept>.

HTH,
Micah

 
 
 

1. "own" vs "uses" vs "contains" vs "is a"

I am studing for a VB exam and the book I have mentions there are
relation types between objects. (New Riders pg. 22 "MCSD Visual Basic
6 Exams 70-175 and 70-176".  (FYI - I did take a course in Object
Oriented Design!)

The book does not give any examples, but I have come up with the
following examples for the relation types that the book says exist. I
came up with the examples etc. from another book by Kurata ( Doing
objects in Visual Basic 6".

My question is how is "contains" different from "has a" I cannot come
up with an example.

"is a" - example a programer "is a" employee. In VB this might be
called a subclass.

"uses" - a data screen "uses a" employee object. In VB this might be
called a collaborator.

"has a" - and employee "has a" time sheet. In VB this might be called
a container.

"contains" -

2. Function evaluation counter in fmins

3. Removing "My Computer", "Recycle Bin" and "Network Neighborhood" from desktop

4. Connection hangs when disconnecting from internet

5. Why "public" "private" "protected"

6. sendmail rejecting connections

7. extern "FORTRAN", extern "Pascal", extern "Ada" ... ?

8. Could not confirm the identity of this server

9. File named "C:\Program" interferes with "C:\Program Files"

10. Short file format: "Progra~1" for "Program Files"

11. "Overwriting a line in a file" -OR- "file pointers?"

12. A "dbx lite" program for "zapping" a running process?