;)
ok, I asked, cause my compiler (VS05) is complaining about the use of
sprintf ....
I guess it's rather ::sprintf (with extern "C" { / #include <stdio.h/ }).
But if you want some safety, you'd use ::snprintf, and if you don't want to implement
the safety yourself, you could rather use lisp^W std::ostringstr eam.
First, AFAIK, C functions are in the "root" namespace; to avoid
refering a different object in the current namespace, it's advised (in
various style guides) to qualify C functions.
Then, using a function without declaring it would make a sane compiler
complain, so it's good practice to include some header declaring it
before using it.
>>"A.Leopold" <andreas.leopol d@himt.dewrites :
>>>
>>>;)
>>>ok, I asked, cause my compiler (VS05) is complaining about the use
>>>of sprintf ....
>>I guess it's rather ::sprintf (with extern "C" { / #include <stdio.h>
>>/ }).
>What would make you guess something like that?
>
First, AFAIK, C functions are in the "root" namespace; to avoid
refering a different object in the current namespace, it's advised (in
various style guides) to qualify C functions.
>
Then, using a function without declaring it would make a sane compiler
complain, so it's good practice to include some header declaring it
before using it.
The is the C++ group here, so the C header <stdio.his to be
included using <cstdioand its content is accessible only within
the 'std' namespace.
"A.Leopold" <andreas.leopol d@himt.dewrites :
>
;)
ok, I asked, cause my compiler (VS05) is complaining about the
use of sprintf ....
>
I guess it's rather ::sprintf (with extern "C" { / #include
<stdio.h/ }).
What would make you guess something like that?
>
First, AFAIK, C functions are in the "root" namespace;
Not (at least theoretically) if you use the headers like <cstdio>.
However, that's not necessary.
to avoid
refering a different object in the current namespace, it's advised (in
various style guides) to qualify C functions.
I've never seen such a thing.
Then, using a function without declaring it would make a sane compiler
complain, so it's good practice to include some header declaring it
before using it.
That's correct, of course. However, <stdio.his a standard C++ header.
Why would you enclose it in extern "C"?
On Oct 9, 8:45 am, "A.Leopold" <andreas.leop.. .@himt.dewrote:
;)
ok, I asked, cause my compiler (VS05) is complaining about the use of
sprintf ....
Please don't top-post.
If you're getting the MSVC warning about depreciated functions, you
may ignore that, or turn off the warning with the appropriate compiler
option, #pragma or #define. Current versions of MSVC warn about the
use of many traditional functions which have the potential, if used
incorrectly, to lead to buffer overflows. MS has taken a fair bit of
heat for this, especially because they chose to describe the functions
as "depreciate d" (which means something specific in terms of the
language standard), instead of something describing the risk. In most
cases they provide a (Microsoft specific) replacement function which
has the potential to be used more easily in a safe way (for example,
the non-standard sprintf_s is offered as a "safer" replacement for
sprintf).
The did it to a number of C++ library functions to. For example,
basic_string::c opy is "depreciate d" while the non-standard
basic_string::_ Copy_s is provided as a "safer" alternative.
Comment