Are Microsoft _s functions now part of the C ++ standard?

I recently changed my IDE to MS Visual Studio 2005, starting with MSVC ++ 6, and I got a lot of warnings about obsolescence. Instead of ignoring the warning, I started changing them to _s equivalents. However, I then found out that these were Microsoft-only implementations.

I read somewhere that they insist that they become part of the standard. It?

Can these _s functions be used? Or should I use something else?

Thanks.

+6
c ++ standards
source share
5 answers

The functions *_s() are not part of the C standard, but there is a pending "Technical Report" offering to add them (I'm not sure if the routines in TR are exactly the same as Microsoft, or if they are just similar).

TR 24731-1: C Library Extensions Part I: Border Validation Interfaces:

If you want to continue to use the old functions, you can safely keep obsolescence warnings by specifying the _CRT_SECURE_NO_WARNINGS macro (there was _CRT_SECURE_NO_DEPRECATE , which can still be supported).

+12
source share

You updated the development environment and updated your Microsoft libraries. Honestly, you can continue to use your old libraries as they are still preserved (for backward compatibility), although Microsoft has stated that they will actually begin to remove some of these old functions. I would say that if you are developing a forward, you can use newer functions; if you are developing in the opposite direction (or are not worried about the version), you can use older functions.

+1
source share

If you are guided by the Microsoft platform, be sure to use them. Even if this is not the case, you can always implement them yourself when (or if) you need to transfer your software to a platform other than Microsoft.

In the worst case, you can use several #ifdef for conditional compilation.

+1
source share

They are considered for standardization, as far as I can tell. Offer TR 24731 .

As to whether it’s good to use them, I would say yes. I don’t really like the way they catch errors, but I believe that you can provide them with your own handler. If you need cross-platform compatibility, you have two options: implement them using macros on platforms other than Windows, or turn off obsolescence warnings.

After viewing the large code base, I decided that it was almost impossible to get all programmers to use the standard library functions correctly for the strings to work correctly, so everything that is aimed at fixing is a nice addition.

+1
source share

You should use standard features and disable any sadistic warnings that Microsoft has enabled by default to prevent writing standard code. I seriously doubt that the "_s" functions will be added to the C standard (although they were proposed) since they are an invention of one vendor and have never been implemented by any other vendor. (Hey, let all POSIX be included in the C standard while we're on it ...)

+1
source share

All Articles