MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.72k stars 254 forks source link

#include<string.h> or #include <cstring> but when use memset with error "use of undeclared identifier memset" #921

Open itongggg opened 1 year ago

itongggg commented 1 year ago

#include <cstring> double a[6]; memset(a, 0, 6); however, i cant call function memset, with error " use of undeclared identifier memset"

itongggg commented 1 year ago
截屏2022-12-05 17 26 56
itongggg commented 1 year ago

this is my .ccls

截屏2022-12-05 17 27 41
madscientist commented 1 year ago

Well, the first thing is that memset() takes three arguments but you are only passing two. That does seem like an odd error for libclang to report for that mistake.

itongggg commented 1 year ago

my bad ,because i used to use bzreo() while even takes three arguments it doesnt change

itongggg commented 1 year ago
截屏2022-12-06 00 09 15
itongggg commented 1 year ago
截屏2022-12-06 22 23 30

i tried this it works but i dont konw why if i need set this as standard .ccls for my other .cpp files

Well, the first thing is that memset() takes three arguments but you are only passing two. That does seem like an odd error for libclang to report for that mistake.

madscientist commented 1 year ago

I don't know either but it sounds like something is weird with your build / install of ccls or gcc, or your OS system files. ccls is built against the libclang library so it will look for system header files wherever libclang would look for them.

Unfortunately I try to avoid Apple products so I can't really help solve issues on MacOS. I suggest you ask the Homebrew folks, where you got this build of ccls and gcc (I assume).