简体   繁体   中英

Why does strcpy_s not exist anywhere on my system?

I'm using clang on a Debian 8 system. I have the standard C++ headers. And yet, there is no header defining strcpy_s . Why is this?

# grep -iRHI 'strcpy_s' /usr 2>/dev/null
/usr/include/x86_64-linux-gnu/bits/string2.h:                ? __strcpy_small (dest, __strcpy_args (src),             \
/usr/include/x86_64-linux-gnu/bits/string2.h:__STRING_INLINE char *__strcpy_small (char *, __uint16_t, __uint16_t,
/usr/include/x86_64-linux-gnu/bits/string2.h:__strcpy_small (char *__dest,
/usr/include/x86_64-linux-gnu/bits/string2.h:__STRING_INLINE char *__strcpy_small (char *, __STRING2_COPY_ARR2,
/usr/include/x86_64-linux-gnu/bits/string2.h:__strcpy_small (char *__dest,
/usr/src/broadcom-sta-6.30.223.248/src/include/bcmutils.h:#define bcm_strcpy_s(dst, noOfElements, src)            strcpy((dst), (src))

Why does strcpy_s not exist anywhere on my system?

strcpy_s is not provided by the C++ standard library.

strcpy_s is however, specified by the C standard standard since C11. But even in C11, strcpy_s is optional. All standard library implementations do not provide all optional features. So, the answer seems to be: Because none of the C standard libraries you have installed declare it.

How to I get strcpy_s, strtok_s, and all the other safe string functions onto my system?

You will need to either find a library that implements them all, or implement them yourself.

Apparently, these don't exist because they don't exist. And I can find and install them by finding and installing them; or, alternatively, by coding them myself. Apparently this is a helpful solution, so let the upvotes begin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM