From: Victor Bazarov on
Robert Kindred wrote:
> "Victor Bazarov" <v.Abazarov(a)comAcast.net> wrote in message
> news:e5mogb$udv$1(a)news.datemas.de...
>> lists(a)givemefish.com wrote:
> []
>>> And, if so, is the suggestion of localtime_s standard compliant?
>>
>> No.
>>
>>> If not, what should I use? [This program has to be
>>> platform-independent, ISO C++.]
>>
>> Keep using 'localtime' until MS comes to its senses (unlikely) or
>> until MS removes it completely from its library implementation (also
>> unlikely). When/If the latter happens, split the code using an ifdef
>> directive.
>
> I am afraid "remove completely" is not so far fetched. I prefer to
> use opendir and readdir to scan directories for a modicum of platform
> independence. This worked in Borland Builder5, but it is gone from
> Microsoft VS2005.

The biggest difference between 'localtime' and 'opendir' or 'readdir'
is that 'localtime' is a _Standard_C_Library_ function, the latter two
aren't.

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



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: kanze on
Bo Persson wrote:
> <lists(a)givemefish.com> skrev i meddelandet
> news:1149149250.643455.166300(a)y43g2000cwc.googlegroups.com...

> > while compiling an existing project in the new MSVC 2005
> > compiler, I received the warning that:

> > : warning C4996: 'localtime' was declared deprecated
> > C:\Program Files\Microsoft Visual Studio
> > 8\VC\include\time.inl(114) : see declaration of 'localtime'
> > Message: 'This function or variable may be unsafe. Consider
> > using localtime_s instead. To disable deprecation, use
> > _CRT_SECURE_NO_DEPRECATE. See online help for details.'

> > I wasn't aware that localtime was declared deprecated. Is
> > this true?

> No. There is a proposal to the C standards committee though. Written
> by Guess Who.

> http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1172.pdf

By who? A priori, by the ISO C committee, according to what I
can see. (As far as I know, Microsoft is not active in WG14.
Although I could be wrong, since I'm only indirectly active in
it myself. And don't forget that between the start of writing,
and the moment the document becomes official, it can easily take
five years.)

Note that there is a problem with localtime in a multithreaded
environment, and that Posix has also proposed a replacement,
required on Posix conformant platforms which support threading.

--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Francis Glassborow on
In article <1149597722.585255.30990(a)i39g2000cwa.googlegroups.com>, kanze
<kanze(a)gabi-soft.fr> writes
>By who? A priori, by the ISO C committee, according to what I
>can see. (As far as I know, Microsoft is not active in WG14.
>Although I could be wrong, since I'm only indirectly active in
>it myself. And don't forget that between the start of writing,
>and the moment the document becomes official, it can easily take
>five years.)

You are mistaken. MS is active in WG14 and has even gone so far as to
employ a consultant C Standards specialist (Randy Meyers) to represent
them on the issue of the library TR (among other things that places a
desirable buffer between their C development teams and the proposals)


--
Francis Glassborow ACCU
Author of 'You Can Do It!' and "You Can Program in C++"
see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Peter C. Chapin on
"kanze" <kanze(a)gabi-soft.fr> wrote in news:1149240208.032430.108300
@g10g2000cwb.googlegroups.com:

>> And, if so, is the suggestion of localtime_s standard compliant?
>
> Not in the strictest sense. It is defined in a TR to C -- sort
> of an official extension. Practically speaking, I would expect
> most C compilers to gradually move to support it, much as C++
> compilers try to support TR1 (except that a lot of C compilers
> aren't moving, period). If the C compiler supports it, you will
> likely get it automatically in C++, even if C++ doesn't (yet)
> recognize the C TR.
>
> For the moment, however, most C compilers, much less most C++
> compilers, do not support it. (The copy of it that I have
> access to is dated Sept. 9, 2005, and it is only a draft. So
> it is very, very new.)

Just an FYI... Open Watcom v1.5 supports TR24731 based on a document dated
2005-10-25. So there is at least one other compiler besides Microsoft's
that supports the *_s functions.

Peter

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Bo Persson on

"kanze" <kanze(a)gabi-soft.fr> skrev i meddelandet
news:1149597722.585255.30990(a)i39g2000cwa.googlegroups.com...
> Bo Persson wrote:
>> <lists(a)givemefish.com> skrev i meddelandet
>> news:1149149250.643455.166300(a)y43g2000cwc.googlegroups.com...
>
>> > while compiling an existing project in the new MSVC 2005
>> > compiler, I received the warning that:
>
>> > : warning C4996: 'localtime' was declared deprecated
>> > C:\Program Files\Microsoft Visual Studio
>> > 8\VC\include\time.inl(114) : see declaration of 'localtime'
>> > Message: 'This function or variable may be unsafe.
>> > Consider
>> > using localtime_s instead. To disable deprecation, use
>> > _CRT_SECURE_NO_DEPRECATE. See online help for details.'
>
>> > I wasn't aware that localtime was declared deprecated. Is
>> > this true?
>
>> No. There is a proposal to the C standards committee though.
>> Written
>> by Guess Who.
>
>> http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1172.pdf
>
> By who?

By the compiler writer, sharing their experience on internal security
projects.

> A priori, by the ISO C committee, according to what I
> can see. (As far as I know, Microsoft is not active in WG14.
> Although I could be wrong, since I'm only indirectly active in
> it myself. And don't forget that between the start of writing,
> and the moment the document becomes official, it can easily take
> five years.)

It almost did.

I was thinking about the original proposal for the new function
signatures, originating from Microsoft (2003).

http://www.open-std.org/JTC1/SC22/WG14/www/docs/n997.pdf

>
> Note that there is a problem with localtime in a multithreaded
> environment, and that Posix has also proposed a replacement,
> required on Posix conformant platforms which support threading.

Sure. My comment were general on deprecating functions in the C
library. Hasn't happened yet, but might happen.

MSVC 2005 marked these functions 'was declared deprecated' rather that
the intended 'is considered insecure', because it was less work doing
so. Someone thought that wasn't a big deal. :-)


Bo Persson



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: VC++ compiler bug?
Next: UTF8 and std::string