Is strcpy_s part of the C++ Standard? Or only part of MS Visual C++
Asked Answered
N

1

0

Using the function strcpy in MS Visual Studio gives me an error saying I should use strcpy_s which is safer to use. Is strcpy_s part of the C++ standard? Or is it only part of Microsoft Visual C++?

Will code containing strcpy_s only compile in Visual Studio?

Nonjuror answered 8/4, 2016 at 4:44 Comment(0)
S
2

strcpy_s() is an optional part of C11 (more formally called a "conditional feature". Implementations are permitted to not implement the "Bounds-checking interfaces" standardized in Annex K.

Some other conditional features of C11 include:

  • atomics
  • complex types
  • threads
  • variable length arrays (the interesting this about this is that VLAs were not optional in C99)
Superstar answered 8/4, 2016 at 5:17 Comment(2)
I see. I have only learned C++ and not C, do most things in the C standard also apply to C++? If so, does that mean that many C++ features are not mentioned in the C++ standard because they were already described in the C standard?Nonjuror
C++11 and C++14 refer to the C99 standard. As far as I know this is still the case in the most recent draft of what's supposed to be C++17. I don't know if there are plans to update C++17 to refer to C11 or not. But even if they do the bounds-checking interfaces would presumably still be optional. As far as I know, the glibc developers are not inclined to implement Annex K. Ulrich Drepper has posted quite negatively about it in the past.Superstar

© 2022 - 2024 — McMap. All rights reserved.