Jean
Jean-Philippe Barette-LaPierre wrote:
> Took from dinkumware.com <http://dinkumware.com> (P. J. Plauger
> <http://en.wikipedia.org/wiki/P._J._Plauger>):
Yep. Yesterday I took a look at the Standard; below is a fragment of current draft of the upcoming Standard
--------------------------------------------
Doc No: N2798=08-0308
Date: 2008-10-04
Reply to: Pete Becker
Roundhouse Consulting, Ltd.
pete at versatilecoding.com
Working Draft, Standard for Programming Language C++
Annex D (normative)
Compatibility features
D.5 C standard library headers [depr.c.headers]
1 For compatibility with the C standard library and the C Unicode TR, the C++ standard library provides
the 25 C headers, as shown in Table 147.
Table 147 — C headers
<assert.h> <float.h> <math.h> <stddef.h> <tgmath.h>
<complex.h> <inttypes.h> <setjmp.h> <stdio.h> <time.h>
<ctype.h> <iso646.h> <signal.h> <stdint.h> <uchar.h>
<errno.h> <limits.h> <stdarg.h> <stdlib.h> <wchar.h>
<fenv.h> <locale.h> <stdbool.h> <string.h> <wctype.h>
2 Every C header, each of which has a name of the form name.h, behaves as if each name placed in the standard
library namespace by the corresponding cname header is placed within the global namespace scope. It is
unspecified whether these names are first declared or defined within namespace scope (3.3.5) of the namespace
std and are then injected into the global namespace scope by explicit using-declarations (7.3.3).
3 [ Example: The header <cstdlib> assuredly provides its declarations and definitions within the namespace
std. It may also provide these names within the global namespace. The header <stdlib.h> assuredly
provides the same declarations and definitions within the global namespace, much as in the C Standard. It
may also provide these names within the namespace std. —end example ]
--------------------------------------------
> So we should just change <string.h> to <cstring>
That's what I thought at first when I saw these headers. After a while because I was convinced we don't use any of the low level functions declared and defined in <cstring> (see below)
--------------------------------------------
20.8.15 C Library
(...)
Table 54 describes the header <cstring>.
7 The contents are the same as the Standard C library header <string.h>, with the change to memchr()
specified in 21.5. See also: ISO C Clause 7.11.2.
Table 54 — Header <cstring> synopsis
Type Name(s)
Macro: NULL
Type: size_t
Functions: memchr memcmp memcpy memmove memset
--------------------------------------------
and because I knew there were compilers which didn't understand <string> only <string.h> (important: to get std::string and not C functions from C++ <cstring>!) I thought Bob added this include as a quick workaround. (But he would need to remove <string> in the same time which he didn't do and I didn't draw a conclusion from this :))
Now I see we indeed use memset in CurlHandle.cpp and because of this we need <cstring> for sure :) But...if we change <string.h> to <cstring> in CurlHandle.cpp we should either add using namespace std; at the beginning or qualify memset with std:: as we don't have any guarantee memset is defined in std namespace if we include <cstring> :)
I checked if we really need headers added by Bob.
in curlpp.cpp we need <cstdlib> for free
in example02 we need <cstring> for strncpy
in example05 we need <cstring> for memcpy
in example06 we need <cstring> for memcpy
in example10 we need <cstdlib> for EXIT_SUCCESS and EXIT_FAILURE
in example11 we need <cstring> for strerror. I see we need also <cstdio> for stdout, stderr, fopen, fwrite, etc.
in example13 we need <cstdlib> for EXIT_SUCCESS and EXIT_FAILURE
in example14 we need <cstdlib> for EXIT_SUCCESS and EXIT_FAILURE
in example21 we need <cstring> for strncpy
From above one can see we really need them all :) I'd propose to add using namespace std in all examples and remove all qualifications to std namespace (std::).
Regards
Piotr Dobrogost
_______________________________________________
cURLpp mailing list
cURLpp_at_rrette.com
http://www.rrette.com/mailman/listinfo/curlpp
Received on 2008-11-20