l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 24: LUGOD election season has begun!
Page last updated:
2006 Dec 30 20:06

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] strerror deprecated?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] strerror deprecated?



Peter Jay Salzman wrote:
Hi all,

Trying to write portable/correct code between Linux and MS Visual C++.

The cl.exe compiler is telling me that "strerror() is deprecated".  Is that
true?  I never heard such a thing.  Tried Googling and couldn't find any
mention of strerror() being deprecated.

The compiler also told me that strerror() was unsafe.  After thinking about
it for a second, I'm guessing it meant "thread unsafe".

Lastly, the compiler told me that I should use strerror_s() which is more
safe.  I looked at the prototype for this function and it requires a buffer,
the buffer's length, and the errno.  Passing a char * to be filled by a
function when you don't know how large of a buffer that function wants
hardly sounds like a good idea.  How should this function be used safely?
Keep allocating memory until the buffer isn't filled all the way?  Sounds
like I would need to write my own strerror function just to make sure the
buffer is large enough.  Why would a standards committee do such a thing?

Lastly, strerror_s doesn't appear in any man pages on my Linux system.
However, it does appear to be similar to strerror_r() which my man pages say
is POSIX compliant (under a suitable #define).

What's the quickest fastest way of using strerror_r if on Linux and
strerror_s if on Windows?

Thanks,
Peter

One solution I have not heard mentioned today: don't use strerror at all.

The few times I have used it in twenty years of programming, it
has been for programs I did not plan on distributing anyway.
Normally, I try to handle all defined errors in a manner appropriate
to the context.  For example, in an embedded system errors may be
reported through LEDs, and ENOMEM is pretty useless information
to the typical user of such a tool.  In reality, errno is pretty
useless information to users in most contexts... it is really
debugging information, and incomplete for that purpose as well.

--
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.