473,406 Members | 2,867 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,406 software developers and data experts.

Why doesn't nothrow work?

This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.

I copied a program from http://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:

p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.

I'm using Bloodshed Dev-C++ Version 4, on Microsoft Windows XP Version
5.1.2600. Any ideas as to what my problem might be?

May 29 '07 #1
16 13255
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not
C+ +.

I copied a program from
http://www.cplusplus.com/doc/tutorial/dynamic.html (if that's a bad
place to go for a tutorial, feel free to direct me elsewhere), and
the following line gets an error:

p= new (nothrow) int[i];
Have you tried

p = new (std::nothrow) int[i];

?
>
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.

I'm using Bloodshed Dev-C++ Version 4, on Microsoft Windows XP Version
5.1.2600. Any ideas as to what my problem might be?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 29 '07 #2
On May 29, 12:02 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not
C+ +.
I copied a program from
http://www.cplusplus.com/doc/tutorial/dynamic.html(if that's a bad
place to go for a tutorial, feel free to direct me elsewhere), and
the following line gets an error:
p= new (nothrow) int[i];

Have you tried

p = new (std::nothrow) int[i];

?
Thanks for the response.

Yes I had tried that, and no, it didn't work. I didn't get the exact
same error messages, but it conveyed the same problem:
`::nothrow' undeclared (first use here)
confused by earlier errors, bailing out
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
I'm using Bloodshed Dev-C++ Version 4, on Microsoft Windows XP Version
5.1.2600. Any ideas as to what my problem might be?

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

May 29 '07 #3
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.

I copied a program from http://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:

p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
Did you #include <new>?
May 29 '07 #4
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.
C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)
I copied a program from http://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:
I don't know exactly, many tutorials in the net have got slight errors
or imperfections.
>
p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
Well, it's not. The brackets are just dummy, and then ignored, and the
token is interpreted as a function reference. But those are
technicalities for a learner, in my opinion. You will learn, with the
experience, to do this:

1) read the error: `nothrow' undeclared
2) why is undeclared? it's standard library! so, try std::nothrow
3) error: ‘nothrow’ is not a member of ‘std’... Damn!
4) why it is not? because everything in c++ has to be defined somewhere,
and all the things of the standard library are defined in a header file
5) pick a book, and check out std::nothrow
6) #include <memory>
7) it works!

;)

Regards,

Zeppe
May 29 '07 #5
On May 29, 12:46 pm, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.

C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)
Yeah... they say that exact same thing over at c.l.python and
c.l.java. I get the feeling everyone's biased or something. ;)
I copied a program fromhttp://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:

I don't know exactly, many tutorials in the net have got slight errors
or imperfections.
p= new (nothrow) int[i];
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.

Well, it's not. The brackets are just dummy, and then ignored, and the
token is interpreted as a function reference. But those are
technicalities for a learner, in my opinion. You will learn, with the
experience, to do this:

1) read the error: `nothrow' undeclared
2) why is undeclared? it's standard library! so, try std::nothrow
3) error: 'nothrow' is not a member of 'std'... Damn!
4) why it is not? because everything in c++ has to be defined somewhere,
and all the things of the standard library are defined in a header file
5) pick a book, and check out std::nothrow
6) #include <memory>
7) it works!

;)

Regards,

Zeppe
Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked, which I must admit is only further confusing for me;
I guess I still have quite a ways to go.

May 29 '07 #6
Dustan wrote:
[..]
Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked, which I must admit is only further confusing for me;
Why is it confusing you? 'nothrow' is a symbol. It needs to be
defined; and it is, in <new>. It is conceivable that <newis
included into <memory(although it doesn't have to be), so when
you include <memory>, you also implicitly include <new(which is
what you actually need for 'nothrow').

It's similar to how 'NULL' is defined pretty much any time you pull
in *any* standard header (probably), while its actual residence is
in <cstddef>, <cstring>, <cstdio>, <ctime>, or <cwchar>. Don't
rely on NULL's definition to exist all the time, do include one of
the required headers for it.
I guess I still have quite a ways to go.
Most of us do, as well.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 29 '07 #7
Dustan wrote:
On May 29, 12:46 pm, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
>Dustan wrote:
>>This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.
C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)

Yeah... they say that exact same thing over at c.l.python and
c.l.java. I get the feeling everyone's biased or something. ;)
>>I copied a program fromhttp://www.cplusplus.com/doc/tutorial/dynamic.html
(if that's a bad place to go for a tutorial, feel free to direct me
elsewhere), and the following line gets an error:
I don't know exactly, many tutorials in the net have got slight errors
or imperfections.
>> p= new (nothrow) int[i];
Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function)
(Each undeclared identifier is reported only once
for each function it appears in.)
confused by earlier errors, bailing out
It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
Well, it's not. The brackets are just dummy, and then ignored, and the
token is interpreted as a function reference. But those are
technicalities for a learner, in my opinion. You will learn, with the
experience, to do this:

1) read the error: `nothrow' undeclared
2) why is undeclared? it's standard library! so, try std::nothrow
3) error: 'nothrow' is not a member of 'std'... Damn!
4) why it is not? because everything in c++ has to be defined somewhere,
and all the things of the standard library are defined in a header file
5) pick a book, and check out std::nothrow
6) #include <memory>
7) it works!

;)

Regards,

Zeppe

Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked, which I must admit is only further confusing for me;
I guess I still have quite a ways to go.
#include <memoryworking is mere coincidence. Your implementation's
version of <memoryreferences <new>. Per the Standard 20.4, <memory>
does not define nothrow. It's defined in <newper 18.4/1.
May 29 '07 #8
red floyd wrote:
Dustan wrote:
>Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked, which I must admit is only further confusing for me;
I guess I still have quite a ways to go.

#include <memoryworking is mere coincidence. Your implementation's
version of <memoryreferences <new>. Per the Standard 20.4, <memory>
does not define nothrow. It's defined in <newper 18.4/1.


Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^

Regards,

Zeppe
May 29 '07 #9
Zeppe wrote:
red floyd wrote:
>Dustan wrote:
>>Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked, which I must admit is only further confusing for me;
I guess I still have quite a ways to go.

#include <memoryworking is mere coincidence. Your implementation's
version of <memoryreferences <new>. Per the Standard 20.4, <memory>
does not define nothrow. It's defined in <newper 18.4/1.

Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^
No, it's more to explain *why* #include <memoryis the wrong answer.
When in doubt, "because the Standard says so", is a good answer.
May 30 '07 #10
red floyd wrote:
Zeppe wrote:
>Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^

No, it's more to explain *why* #include <memoryis the wrong answer.
When in doubt, "because the Standard says so", is a good answer.
I hope you will agree that it's unlikely that the OP will read the
standard... anyway, I didn't want to argue about that, sure citing the
standard is always the best way to solve a doubt (for me, it would have
been enough "nothrow is defined in new, not in memory", and I would have
checked it out), but sometimes, particularly when a beginner asks
something, it can sound a little bit harsh, you know, bumptious.

Just my personal impression, though..

Regards,

Zeppe
May 30 '07 #11
On May 30, 3:54 am, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
red floyd wrote:
Zeppe wrote:
Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^
No, it's more to explain *why* #include <memoryis the wrong answer.
When in doubt, "because the Standard says so", is a good answer.

I hope you will agree that it's unlikely that the OP will read the
standard...
Show me the standard and I'll look at it. It looks like it'll help me
break through some of the issues I'm experiencing.
anyway, I didn't want to argue about that, sure citing the
standard is always the best way to solve a doubt (for me, it would have
been enough "nothrow is defined in new, not in memory", and I would have
checked it out), but sometimes, particularly when a beginner asks
something, it can sound a little bit harsh, you know, bumptious.

Just my personal impression, though..

Regards,

Zeppe

May 30 '07 #12
Dustan wrote:
On May 30, 3:54 am, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
>red floyd wrote:
>>Zeppe wrote:
Citing the standard, I guess, is to simplify the things to the beginner,
isn't it? Anyway, you caught me, I didn't really checked up in the book ^^
No, it's more to explain *why* #include <memoryis the wrong answer.
When in doubt, "because the Standard says so", is a good answer.
I hope you will agree that it's unlikely that the OP will read the
standard...

Show me the standard and I'll look at it. It looks like it'll help me
break through some of the issues I'm experiencing.
The standard is not very easy to look at, much better a good book for
the beginners (like the stroustrup). It isn't even available for free.
The draft is available, and it's quite close to the actual standard:
ftp://ftp.research.att.com/dist/c++std/WP/CD2

Regards,

Zeppe
May 30 '07 #13
Zeppe wrote:
>
The standard is not very easy to look at, much better a good book for
the beginners (like the stroustrup). It isn't even available for free.
The draft is available, and it's quite close to the actual standard:
ftp://ftp.research.att.com/dist/c++std/WP/CD2
It's close to the 1998 standard. It's a long ways from the 2003
standard. Why is it that so many "professional" programmers aren't
willing to pay $30 for current information?

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
May 30 '07 #14
On May 30, 10:57 am, Pete Becker <p...@versatilecoding.comwrote:
Zeppe wrote:
The standard is not very easy to look at, much better a good book for
the beginners (like the stroustrup). It isn't even available for free.
The draft is available, and it's quite close to the actual standard:
ftp://ftp.research.att.com/dist/c++std/WP/CD2

It's close to the 1998 standard. It's a long ways from the 2003
standard. Why is it that so many "professional" programmers aren't
willing to pay $30 for current information?
Because I'm not professional???
--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)

May 30 '07 #15
On Tue, 29 May 2007 09:56:13 -0700, Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+ +
for more than about 10 seconds: it doesn't work. I've been able to get
java and (of course) python programs to compile and run, but not C+ +.

I copied a program from
http://www.cplusplus.com/doc/tutorial/dynamic.html (if that's a bad
place to go for a tutorial, feel free to direct me elsewhere), and the
following line gets an error:

p= new (nothrow) int[i];

Here are the errors I get (all on line 11, the one above):
`nothrow' undeclared (first use this function) (Each undeclared
identifier is reported only once for each function it appears in.)
confused by earlier errors, bailing out

It seems odd to me that it's calling 'nothrow' a function; is (XXX)
really valid functional notation in C++? I thought that syntax was
reserved for casts.
It is not calling `nothrow' a function. "first use this function" is
short for "the given position is the first use of this particular
undeclared identifier in this function". And the actual function name is
also part of the error message.

--
Markus Schoder
May 30 '07 #16
In article <11*********************@k79g2000hse.googlegroups. com>,
Du**********@gmail.com says...
On May 29, 12:46 pm, Zeppe
<zep_p@.remove.all.this.long.comment.yahoo.itwrote :
Dustan wrote:
This is the biggie that has been keeping me from even trying to use C+
+ for more than about 10 seconds: it doesn't work. I've been able to
get java and (of course) python programs to compile and run, but not C+
+.
C++ it's a little bit tricky but when you know how to use it it's very
powerful, more than python or java. It's worth the time ;)

Yeah... they say that exact same thing over at c.l.python and
c.l.java. I get the feeling everyone's biased or something. ;)
It's necessarily that anybody's biased -- it's just that "powerful"
doesn't really mean much about a programming language. C++ gives lots of
control at a finer level of detail than most other languages. In
exchange for that, it _requires_ you to control more of what's going on,
even in cases where most other languages provide a single option (or
perhaps a default option) that usually makes sense.

[ ... ]
Thanks to red floyd and Zeppe for their responses. Both <newand
<memoryworked, which I must admit is only further confusing for me;
I guess I still have quite a ways to go.
<newis where the standard says nothrow is defined. The C++ standard
allows inclusion of one standard header to also have the effect of
including any other standard headers the implementation chooses.

That's undoubtedly what's happening in the case of including <memory--
on your implementation, it's including <newindirectly; it's not
required to do so, however, so what you want to include is <new>.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jun 3 '07 #17

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

Similar topics

6
by: Chewy509 | last post by:
Hi Everyone, I'll just start, and say I am not a PHP developer (I'm a sysadmin, who has gotten lumped with a non-working website). But since I like to do this type of stuff, I though I might...
4
by: Chris Lount | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I'm pretty new to c++ . I'm trying to work out why the following code doesn't work. I've just learned about cin.get() and written the following...
3
by: OM | last post by:
Why doesn't a onmouseover function work in a function? (It's prob due to my code being wrong more than anything else!) I've got the following code (snippet): <!-- Begin var image0 = new...
6
by: JustSomeGuy | last post by:
unsigned short x; ifstream cin; // opened in binary mode. cin >> x; // Doesn't work. yet cin.read((char *) &x, sizeof(x)); works...
3
by: Iver Erling Årva | last post by:
Can anyone please tell me why this doesn't work? The sign changes when I hit the button, and I get no error messages, but the textarea doesn't disappear/reappear. <html> <head> <title>New...
10
by: Brett | last post by:
This code is supposed to work in Netscape 4+ and IE 4+. It works fine in IE but in Netscape 7.2, I get a blank page. Any suggestions? Thanks, Brett <html> <head>
3
by: MeNotHome | last post by:
I am trying to automate web browser navigation and form fill out in vb.net Why doesn't this work? AxWebBrowser1.Document.Forms(0).All("action-download").click() I also tried...
3
by: Joey | last post by:
I am working on an asp.net 1.1 web app in C#. I downloaded some sample code that is supposed to allow for me to persist session state. The code is as follows: private void PersistSessionState()...
7
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/xml.html The first alert() shows the XML that the server is returning. The second alert() shows a particular elements nodeValue and, as you can see,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.