CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2001
    Posts
    1,029

    strerror deprecated?

    Hello,

    In Windows I get:

    warning C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

    When I try to compile this line:

    cerr << "ERROR: recvfrom(): " << strerror(errno) << endl;

    I know its not deprecated, but is there a better function to do what I am trying to do? One without warnings?

    Thanks!

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: strerror deprecated?

    I would say just disable those warnings, but that's just me......

  3. #3
    Join Date
    Apr 2001
    Posts
    1,029

    Re: strerror deprecated?

    this is for a library that people will compile on other machines though.. so I was looking for a way for them not to have warnings.. you know?

  4. #4
    Join Date
    Apr 2001
    Posts
    1,029

    Re: strerror deprecated?

    by the way Lindley.. do you know if cerr is ok to use for all applications? like windows console, dialog based apps, etc?

  5. #5
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: strerror deprecated?

    Quote Originally Posted by lab1
    this is for a library that people will compile on other machines though.. so I was looking for a way for them not to have warnings.. you know?
    Provide them with project configuration files such that the warning is disabled.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: strerror deprecated?

    Quote Originally Posted by laserlight View Post
    Provide them with project configuration files such that the warning is disabled.
    If COMPILER portability is not a major concern, I would recommend push/pop around those cases where you specifically KNOW it is safe....

    For example the posted code is NOT thread safe, while the recommended replacement IS.

    The ONLY time I deiable the warning (or use the #define to accomplish the same thing) is when I have a large codebase provided by another vendor that I am not going to be making (significant) modifications to....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured