linux下c11使用memcpy_s,c - 将c11标准与clang一起使用以使用strcpy_s - 堆栈内存溢出

我正在运行OS X Sierra并尝试编译使用strcpy_s ac程序,但是我安装的clang编译器正在使用c99标准,但是从我的阅读中来看strcpy_s需要c11。

这是我要编译的代码

#include

#include

#include

int main(void)

{

char source[] = "Test string";

char destination[50];

if(strcpy_s(destination, sizeof(destination), source))

printf("string copied - %s",destination);

return 0;

}

这是我用来编译的命令

$ clang copytest.c -o copytest

copytest.c:11:5: warning: implicit declaration of function 'strcpy_s' is invalid in C99 [-Wimplicit-function-declaration]

if(strcpy_s(copied_string, sizeof(copied_string), source))

^

1 warning generated.

Undefined symbols for architecture x86_64:

"_strcpy_s", referenced from:

_main in copytest-e1e05a.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

我尝试使用标准标志进行编译...

clang -std=c11 copytest.c -o copytest

但是我得到了完全相同的“在c99中无效”警告。 我也尝试使用gcc进行编译,但仍然收到相同的c99警告。

我尝试通过自制程序进行升级,显示以下内容

警告:gcc 9.2.0已经安装并且是最新的

我有clang版本9.0.0

$ clang -v

Apple LLVM version 9.0.0 (clang-900.0.39.2)

我的xcode版本是Xcode 9.2,从我读过的所有内容中都应该带有c11支持。

我在编译时做错什么了吗,我的代码本身是错误的吗? 这是我在这里发现的唯一类似问题,但甚至没有答案。 谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值