vscode 提示 identifier "" is undefined 但是编译却能通过

现象

vscode上报错 identifier "strcpy" is undefined,但是编译却能通过。

原因

出现这种情况是因为 cpptools 的 includePath 配置错误,导致代码阅读时出现错误提示。

解决办法

此时只需要正确配置 includePath 即可消除提示信息。

1、终端执行命令 gcc -v -E -x c -

 

 2、打开 vscode 按 command+shift+p,搜索 c/c++:Edit Configurations(JSON)

 

 3、将步骤一中得到的路径,添加到 includePath 里

 

posted @ 2022-11-08 20:27  郝姬友  阅读(1206)  评论(0编辑  收藏  举报