Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++.moderated > #7369 > unrolled thread
| Started by | Joe Bentley <joe.foxhound@googlemail.com> |
|---|---|
| First post | 2016-02-16 07:03 -0600 |
| Last post | 2016-02-16 12:32 -0600 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.c++.moderated
Is <cstdlib> required? Joe Bentley <joe.foxhound@googlemail.com> - 2016-02-16 07:03 -0600
Re: Is <cstdlib> required? Bo Persson <bop@gmb.dk> - 2016-02-16 12:32 -0600
| From | Joe Bentley <joe.foxhound@googlemail.com> |
|---|---|
| Date | 2016-02-16 07:03 -0600 |
| Subject | Is <cstdlib> required? |
| Message-ID | <aaa44aee-e02a-4be7-a94d-2d4ac57773d3@googlegroups.com> |
Is the <cstdlib> header file required? I have noticed that in some
implementations it appears to be automatically included. Maybe it's picked
up by <iostream> or some other common header file, but I can't find any
reference on this. Does the "standard" have anything to say on its
inclusion by other header files?
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[toc] | [next] | [standalone]
| From | Bo Persson <bop@gmb.dk> |
|---|---|
| Date | 2016-02-16 12:32 -0600 |
| Message-ID | <dih4hkFs0mfU1@mid.individual.net> |
| In reply to | #7369 |
On 2016-02-16 14:03, Joe Bentley wrote:
>
> Is the <cstdlib> header file required? I have noticed that in some
> implementations it appears to be automatically included. Maybe it's
picked
> up by <iostream> or some other common header file, but I can't find any
> reference on this. Does the "standard" have anything to say on its
> inclusion by other header files?
>
>
You should include the headers of the things you use. That's the simple
rule.
The standard says that any C++ header may include any other C++ header,
as needed. Relying on one header including some other header makes your
code non-portable, as the next compiler might include another set of
headers.
For <iostream> in particular, the standard makes an exception and
explicitly requires these includes:
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
Whether any of those in turn includes <cstdlib> is not specified.
Bo Persson
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c++.moderated
csiph-web